File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -76,15 +76,15 @@ impl TempFile {
76
76
}
77
77
78
78
// When TempFile is dropped:
79
- // 1. First, the File will be automatically closed (Drop for File)
80
- // 2. Then our drop implementation will remove the file
79
+ // 1. First, our drop implementation will remove the file's name from the filesystem.
80
+ // 2. Then, File's drop will close the file, removing its underlying content from the disk.
81
81
impl Drop for TempFile {
82
82
fn drop(&mut self) {
83
- // Note: File is already closed at this point
84
83
if let Err(e) = std::fs::remove_file(&self.path) {
85
84
eprintln!("Failed to remove temporary file: {}", e);
86
85
}
87
86
println!("> Dropped temporary file: {:?}", self.path);
87
+ // File's drop is implicitly called here because it is a field of this struct.
88
88
}
89
89
}
90
90
You can’t perform that action at this time.
0 commit comments