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

Commit

Permalink
Merge pull request #39 from rfdonnelly/fix-ignored-error-in-example
Browse files Browse the repository at this point in the history
Fix ignored error in example
  • Loading branch information
KodrAus authored Jan 2, 2018
2 parents fe3ce17 + 9ecf401 commit 41377a0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ This sample method does the following:
5. Close the directory, deleting the contents in the process.

```rust
fn write_temp_folder_with_files() -> Result<(), io::Error> {
if let Ok(dir) = TempDir::new("my_directory_prefix") {
let file_path = dir.path().join("foo.txt");
println!("{:?}", file_path);

let mut f = File::create(file_path)?;
f.write_all(b"Hello, world!")?;
f.sync_all()?;
dir.close()?;
}
use std::io::{self, Write};
use std::fs::File;
use tempdir::TempDir;

fn write_temp_folder_with_files() -> io::Result<()> {
let dir = TempDir::new("my_directory_prefix")?;
let file_path = dir.path().join("foo.txt");
println!("{:?}", file_path);

let mut f = File::create(file_path)?;
f.write_all(b"Hello, world!")?;
f.sync_all()?;
dir.close()?;

Ok(())
}
```
Expand Down

0 comments on commit 41377a0

Please sign in to comment.