Open osa1 opened 1 year ago
I tried it, the file is not deleted immediately.
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let t = tempfile::NamedTempFile::new()?;
let tpath = t.into_temp_path();
let path = tpath.to_path_buf();
assert!(path.is_file());
tpath.close()?;
assert!(!path.is_file());
Ok(())
}
Hm. Yeah, this needs to be improved. The idea was to downgrade a named temporary file into an unnamed temporary file where:
NamedTempFile::into_file
says "The inner file will be deleted".It's unclear what that means. I'm assuming it means the temp file will be deleted when the Rust
File
returned byinto_file
is dropped, but it could also mean that the file will be deleted immediately, but the file handle will still be usable (like ininto_parts
).Could you clarify this please?