Skip to content

Commit 1d277a3

Browse files
committed
Add documentation of why we forget the File after closing the inner file
1 parent fdc2cc5 commit 1d277a3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

text/0000-close-trait.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ As it currently stands, there shall be no default implementation.
9090
## File
9191

9292
This trait will be implemented for `fs::File` with `Error` specified as
93-
`io::Error`.
94-
95-
In `src/libstd/fs.rs`:
93+
`io::Error`. Similarly to how other methods are implemented on the inner `File`
94+
implementations, `close` takes `self.inner` by reference (see below). Thus we
95+
must `forget` the `File` to prevent a double free. To do this we place this
96+
impl block in `src/libstd/fs.rs`:
9697

9798
```rust
9899
impl Close for File {

0 commit comments

Comments
 (0)