diff --git a/Cargo.toml b/Cargo.toml index f2d7c9cf..b0334da6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lib.rs b/src/lib.rs index 9473b2ca..b90d1bcf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -360,7 +360,7 @@ impl MmapOptions { /// /// ``` /// # extern crate memmap2; - /// # extern crate tempdir; + /// # extern crate tempfile; /// # /// use std::fs::OpenOptions; /// use std::path::PathBuf; @@ -368,7 +368,7 @@ impl MmapOptions { /// 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)?; @@ -575,7 +575,7 @@ impl Mmap { /// /// ``` /// # extern crate memmap2; - /// # extern crate tempdir; + /// # extern crate tempfile; /// # /// use memmap2::Mmap; /// use std::ops::DerefMut; @@ -583,7 +583,7 @@ impl Mmap { /// # 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) @@ -702,7 +702,7 @@ impl MmapRaw { /// /// ``` /// # extern crate memmap2; - /// # extern crate tempdir; + /// # extern crate tempfile; /// # /// use std::fs::OpenOptions; /// use std::io::Write; @@ -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)?; @@ -822,7 +822,7 @@ impl MmapMut { /// /// ``` /// # extern crate memmap2; - /// # extern crate tempdir; + /// # extern crate tempfile; /// # /// use std::fs::OpenOptions; /// use std::path::PathBuf; @@ -830,7 +830,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("map_mut"); /// let file = OpenOptions::new() @@ -871,7 +871,7 @@ impl MmapMut { /// /// ``` /// # extern crate memmap2; - /// # extern crate tempdir; + /// # extern crate tempfile; /// # /// use std::fs::OpenOptions; /// use std::io::Write; @@ -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)?; @@ -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; @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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); @@ -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(); @@ -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(); @@ -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(); @@ -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()