Skip to content

Commit

Permalink
Replace tempdir crate with tempfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkjall authored Feb 13, 2022
1 parent a336dc8 commit d8863a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ stable_deref_trait = { version = "1.0", optional = true }
libc = "0.2"

[dev-dependencies]
tempdir = "0.3"
tempfile = "3"
owning_ref = "0.4.1"
48 changes: 24 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ impl MmapOptions {
///
/// ```
/// # extern crate memmap2;
/// # extern crate tempdir;
/// # extern crate tempfile;
/// #
/// use std::fs::OpenOptions;
/// use std::path::PathBuf;
///
/// use memmap2::MmapOptions;
/// #
/// # fn main() -> std::io::Result<()> {
/// # let tempdir = tempdir::TempDir::new("mmap")?;
/// # let tempdir = tempfile::tempdir()?;
/// let path: PathBuf = /* path to file */
/// # tempdir.path().join("map_mut");
/// let file = OpenOptions::new().read(true).write(true).create(true).open(&path)?;
Expand Down Expand Up @@ -575,15 +575,15 @@ impl Mmap {
///
/// ```
/// # extern crate memmap2;
/// # extern crate tempdir;
/// # extern crate tempfile;
/// #
/// use memmap2::Mmap;
/// use std::ops::DerefMut;
/// use std::io::Write;
/// # use std::fs::OpenOptions;
///
/// # fn main() -> std::io::Result<()> {
/// # let tempdir = tempdir::TempDir::new("mmap")?;
/// # let tempdir = tempfile::tempdir()?;
/// let file = /* file opened with write permissions */
/// # OpenOptions::new()
/// # .read(true)
Expand Down Expand Up @@ -702,7 +702,7 @@ impl MmapRaw {
///
/// ```
/// # extern crate memmap2;
/// # extern crate tempdir;
/// # extern crate tempfile;
/// #
/// use std::fs::OpenOptions;
/// use std::io::Write;
Expand All @@ -712,7 +712,7 @@ impl MmapRaw {
/// use memmap2::MmapRaw;
///
/// # fn main() -> std::io::Result<()> {
/// let tempdir = tempdir::TempDir::new("mmap")?;
/// let tempdir = tempfile::tempdir()?;
/// let path: PathBuf = /* path to file */
/// # tempdir.path().join("flush");
/// let file = OpenOptions::new().read(true).write(true).create(true).open(&path)?;
Expand Down Expand Up @@ -822,15 +822,15 @@ impl MmapMut {
///
/// ```
/// # extern crate memmap2;
/// # extern crate tempdir;
/// # extern crate tempfile;
/// #
/// use std::fs::OpenOptions;
/// use std::path::PathBuf;
///
/// use memmap2::MmapMut;
/// #
/// # fn main() -> std::io::Result<()> {
/// # let tempdir = tempdir::TempDir::new("mmap")?;
/// # let tempdir = tempfile::tempdir()?;
/// let path: PathBuf = /* path to file */
/// # tempdir.path().join("map_mut");
/// let file = OpenOptions::new()
Expand Down Expand Up @@ -871,7 +871,7 @@ impl MmapMut {
///
/// ```
/// # extern crate memmap2;
/// # extern crate tempdir;
/// # extern crate tempfile;
/// #
/// use std::fs::OpenOptions;
/// use std::io::Write;
Expand All @@ -880,7 +880,7 @@ impl MmapMut {
/// use memmap2::MmapMut;
///
/// # fn main() -> std::io::Result<()> {
/// # let tempdir = tempdir::TempDir::new("mmap")?;
/// # let tempdir = tempfile::tempdir()?;
/// let path: PathBuf = /* path to file */
/// # tempdir.path().join("flush");
/// let file = OpenOptions::new().read(true).write(true).create(true).open(&path)?;
Expand Down Expand Up @@ -1033,7 +1033,7 @@ impl fmt::Debug for MmapMut {

#[cfg(test)]
mod test {
extern crate tempdir;
extern crate tempfile;

#[cfg(unix)]
use crate::advice::Advice;
Expand All @@ -1052,7 +1052,7 @@ mod test {
#[test]
fn map_file() {
let expected_len = 128;
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand Down Expand Up @@ -1085,7 +1085,7 @@ mod test {
#[cfg(unix)]
fn map_fd() {
let expected_len = 128;
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand Down Expand Up @@ -1117,7 +1117,7 @@ mod test {
/// Checks that "mapping" a 0-length file derefs to an empty slice.
#[test]
fn map_empty_file() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand Down Expand Up @@ -1159,7 +1159,7 @@ mod test {

#[test]
fn file_write() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let mut file = OpenOptions::new()
Expand All @@ -1183,7 +1183,7 @@ mod test {

#[test]
fn flush_range() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand All @@ -1209,7 +1209,7 @@ mod test {

#[test]
fn map_copy() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let mut file = OpenOptions::new()
Expand Down Expand Up @@ -1245,7 +1245,7 @@ mod test {

#[test]
fn map_copy_read_only() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand All @@ -1270,7 +1270,7 @@ mod test {

#[test]
fn map_offset() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let file = OpenOptions::new()
Expand Down Expand Up @@ -1356,7 +1356,7 @@ mod test {
#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn jit_x86_file() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let mut options = OpenOptions::new();
#[cfg(windows)]
options.access_mode(GENERIC_ALL);
Expand All @@ -1374,7 +1374,7 @@ mod test {

#[test]
fn mprotect_file() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let mut options = OpenOptions::new();
Expand Down Expand Up @@ -1420,7 +1420,7 @@ mod test {

#[test]
fn mprotect_copy() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap");

let mut options = OpenOptions::new();
Expand Down Expand Up @@ -1477,7 +1477,7 @@ mod test {

#[test]
fn raw() {
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmapraw");

let mut options = OpenOptions::new();
Expand Down Expand Up @@ -1516,7 +1516,7 @@ mod test {
#[cfg(unix)]
fn advise() {
let expected_len = 128;
let tempdir = tempdir::TempDir::new("mmap").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("mmap_advise");

let file = OpenOptions::new()
Expand Down

0 comments on commit d8863a9

Please sign in to comment.