Skip to content

Commit

Permalink
Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Document that DirEntry holds the directory open

I had a bug where holding onto DirEntry structs caused file descriptor exhaustion, and thought it would be good to document this.
  • Loading branch information
Dylan-DPC authored Apr 13, 2022
2 parents d449a63 + 7cdef08 commit 032358b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ pub struct ReadDir(fs_imp::ReadDir);
/// An instance of `DirEntry` represents an entry inside of a directory on the
/// filesystem. Each entry can be inspected via methods to learn about the full
/// path or possibly other metadata through per-platform extension traits.
///
/// # Platform-specific behavior
///
/// On Unix, the `DirEntry` struct contains an internal reference to the open
/// directory. Holding `DirEntry` objects will consume a file handle even
/// after the `ReadDir` iterator is dropped.
///
/// Note that this [may change in the future][changes].
///
/// [changes]: io#platform-specific-behavior
#[stable(feature = "rust1", since = "1.0.0")]
pub struct DirEntry(fs_imp::DirEntry);

Expand Down

0 comments on commit 032358b

Please sign in to comment.