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 {
7676}
7777
7878// 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.
8181impl Drop for TempFile {
8282 fn drop(&mut self) {
83- // Note: File is already closed at this point
8483 if let Err(e) = std::fs::remove_file(&self.path) {
8584 eprintln!("Failed to remove temporary file: {}", e);
8685 }
8786 println!("> Dropped temporary file: {:?}", self.path);
87+ // File's drop is implicitly called here because it is a field of this struct.
8888 }
8989}
9090
You can’t perform that action at this time.
0 commit comments