Skip to content
This repository was archived by the owner on Aug 20, 2021. It is now read-only.

Commit 4bbb0a8

Browse files
committed
Fix ignored Error in example
Previous to this change, the Err result from TempDir::new was silently ignored. Fix by handling the Err result using the '?' operator.
1 parent c69f5b2 commit 4bbb0a8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ This sample method does the following:
3636

3737
```rust
3838
fn write_temp_folder_with_files() -> Result<(), io::Error> {
39-
if let Ok(dir) = TempDir::new("my_directory_prefix") {
40-
let file_path = dir.path().join("foo.txt");
41-
println!("{:?}", file_path);
42-
43-
let mut f = File::create(file_path)?;
44-
f.write_all(b"Hello, world!")?;
45-
f.sync_all()?;
46-
dir.close()?;
47-
}
39+
let dir = TempDir::new("my_directory_prefix")?;
40+
let file_path = dir.path().join("foo.txt");
41+
println!("{:?}", file_path);
42+
43+
let mut f = File::create(file_path)?;
44+
f.write_all(b"Hello, world!")?;
45+
f.sync_all()?;
46+
dir.close()?;
47+
4848
Ok(())
4949
}
5050
```

0 commit comments

Comments
 (0)