Logo

Programming-Idioms

History of Idiom 138 > diff from v27 to v28

Edit summary for version 28 by programming-idioms.org:
[Rust] Emphasis in comments

Version 27

2020-10-08, 13:00:51

Version 28

2021-03-27, 19:16:37

Idiom #138 Create temp file

Create a new temporary file on filesystem.

Idiom #138 Create temp file

Create a new temporary file on filesystem.

Imports
use tempdir::TempDir;
use std::fs::File;
Imports
use tempdir::TempDir;
use std::fs::File;
Code
let temp_dir = TempDir::new("prefix")?;
let temp_file = File::open(temp_dir.path().join("file_name"))?;
Code
let temp_dir = TempDir::new("prefix")?;
let temp_file = File::open(temp_dir.path().join("file_name"))?;
Comments bubble
TempDir deletes the directory and its contents when it is dropped.
Comments bubble
TempDir deletes the directory and its contents when it is dropped.
Doc URL
https://docs.rs/tempdir/0.3.7/tempdir/struct.TempDir.html#method.new
Doc URL
https://docs.rs/tempdir/0.3.7/tempdir/struct.TempDir.html#method.new
Origin
https://docs.rs/tempdir/0.3.7/tempdir/struct.TempDir.html#method.new
Origin
https://docs.rs/tempdir/0.3.7/tempdir/struct.TempDir.html#method.new