fomat-macros
fomat-macros copied to clipboard
replace tempdir with tempfile, as tempdir is deprecated
deprecation note here: https://crates.io/crates/tempdir
This PR changes semantics of that part of code. To use the equivalent of deprecated tempdir::TempDir::new()
you need to use builder to pass the prefix.
Like that:
diff --git a/Cargo.toml b/Cargo.toml
index 78655eb..42dee13 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,4 @@ license = "MIT"
[dev-dependencies]
tar = "0.4.9"
-tempdir = "0.3.5"
+tempfile = "3.3.0"
diff --git a/tests/capturing.rs b/tests/capturing.rs
index 551cc91..2f93e0f 100644
--- a/tests/capturing.rs
+++ b/tests/capturing.rs
@@ -1,7 +1,8 @@
-extern crate tempdir;
+extern crate tempfile;
extern crate tar;
use std::path::Path;
+use tempfile::Builder;
const FILES: &'static [(&'static str, &'static str)] = &[
("Cargo.toml", r#"
@@ -83,8 +84,8 @@ fn capturing() {
rootdir
};
- let pintdir = tempdir::TempDir::new("fomat-macros-capturing-test")
- .expect("Can't create tempdir");
+ let pintdir = Builder::new()
+ .expect("Can't create tempdir");
unpack_files(pintdir.as_ref(), rootdir.to_str().unwrap());
assert!(
? E: This errors because unpack_files expects a path type:
expected struct `Path`, found struct `tempfile::Builder`
From memory more like:
let pintdir = Builder::new()
.prefix("my-temporary-note")
.tempdir()
.expect("Can't create tempdir");
This builds fine for me:
diff --git a/Cargo.toml b/Cargo.toml
index 78655eb..42dee13 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,4 @@ license = "MIT"
[dev-dependencies]
tar = "0.4.9"
-tempdir = "0.3.5"
+tempfile = "3.3.0"
diff --git a/tests/capturing.rs b/tests/capturing.rs
index 551cc91..925313b 100644
--- a/tests/capturing.rs
+++ b/tests/capturing.rs
@@ -1,7 +1,8 @@
-extern crate tempdir;
+extern crate tempfile;
extern crate tar;
use std::path::Path;
+use tempfile::Builder;
const FILES: &'static [(&'static str, &'static str)] = &[
("Cargo.toml", r#"
@@ -83,9 +84,11 @@ fn capturing() {
rootdir
};
- let pintdir = tempdir::TempDir::new("fomat-macros-capturing-test")
- .expect("Can't create tempdir");
- unpack_files(pintdir.as_ref(), rootdir.to_str().unwrap());
+ let pintdir = Builder::new()
+ .prefix("my-temporary-note")
+ .tempdir()
+ .expect("Can't create tempdir");
+ unpack_files( &pintdir.path(), rootdir.to_str().unwrap());
assert!(
Command::new("cargo").arg("build")
Please merge.
@michalfita updated to preserve the prefix
Looks good to me now.