Skip to content

Commit dd26bc8

Browse files
authored
Merge pull request #1953 from jamm-es/master
Fix drop order explanation in trait > drop
2 parents ad27f82 + 893de44 commit dd26bc8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/trait/drop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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.
8181
impl 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

0 commit comments

Comments
 (0)