From 6f5f068e7092732abfc57d3de48663b1aeeba1ed Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 4 Feb 2024 22:13:36 +0100 Subject: [PATCH] using an absolute path to create a file --- examples/demo/src/tests/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/demo/src/tests/mod.rs b/examples/demo/src/tests/mod.rs index ad0702707..450e95b0b 100644 --- a/examples/demo/src/tests/mod.rs +++ b/examples/demo/src/tests/mod.rs @@ -128,19 +128,19 @@ pub fn read_dir() -> Result<(), std::io::Error> { pub fn create_file() -> Result<(), std::io::Error> { { - let mut file = File::create("foo.txt")?; + let mut file = File::create("/tmp/foo.txt")?; file.write_all(b"Hello, world!")?; } let content = { - let mut file = File::open("foo.txt")?; + let mut file = File::open("/tmp/foo.txt")?; let mut content = String::new(); file.read_to_string(&mut content)?; content }; // delete temporary file - std::fs::remove_file("foo.txt")?; + std::fs::remove_file("/tmp/foo.txt")?; if content == "Hello, world!" { Ok(())