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

Commit 41377a0

Browse files
authored
Merge pull request #39 from rfdonnelly/fix-ignored-error-in-example
Fix ignored error in example
2 parents fe3ce17 + 9ecf401 commit 41377a0

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ This sample method does the following:
3535
5. Close the directory, deleting the contents in the process.
3636

3737
```rust
38-
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-
}
38+
use std::io::{self, Write};
39+
use std::fs::File;
40+
use tempdir::TempDir;
41+
42+
fn write_temp_folder_with_files() -> io::Result<()> {
43+
let dir = TempDir::new("my_directory_prefix")?;
44+
let file_path = dir.path().join("foo.txt");
45+
println!("{:?}", file_path);
46+
47+
let mut f = File::create(file_path)?;
48+
f.write_all(b"Hello, world!")?;
49+
f.sync_all()?;
50+
dir.close()?;
51+
4852
Ok(())
4953
}
5054
```

0 commit comments

Comments
 (0)