mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/utils: Improve TemporaryDirectory APIs
Rename the previous "default" `new` constructor [1] to `with_prefix` and add a new default `new` constructor that takes no argument is therefore easier to use. In addition, improve the overall documentation, add more tests, and examples to the code. [1] https://doc.rust-lang.org/nomicon/constructors.html Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
committed by
Steffen Eiden
parent
2f3c189fda
commit
079ae1e24d
@@ -246,7 +246,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sysfs_write_i32() {
|
||||
let temp_dir =
|
||||
TemporaryDirectory::new("pvtests").expect("creating a temporary directory should work");
|
||||
TemporaryDirectory::new().expect("creating a temporary directory should work");
|
||||
let test_path = temp_dir.path().join("test");
|
||||
let test_path = test_path.as_os_str().to_str().expect("should work");
|
||||
let mut file = File::create(test_path).unwrap();
|
||||
@@ -264,7 +264,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_lockfile() {
|
||||
let temp_dir =
|
||||
TemporaryDirectory::new("pvtests").expect("creating a temporary directory should work");
|
||||
TemporaryDirectory::new().expect("creating a temporary directory should work");
|
||||
let file_path = temp_dir.path().join("my.lock");
|
||||
let file_path_str = file_path.to_str().expect("should work");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user