diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-13 17:35:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-13 17:35:33 +0200 |
| commit | 032358bd30d2eaa31cdec4a40d8a4703fbec22cc (patch) | |
| tree | ac0bec5f827ae4b6d71528ca7d0585020e6d61ce /library/std/src | |
| parent | d449a63e93c65ec5272e87e4532ec1992d4f2dab (diff) | |
| parent | 7cdef0876deb12e3a5a69c9dec2b386fa61a4384 (diff) | |
| download | rust-032358bd30d2eaa31cdec4a40d8a4703fbec22cc.tar.gz rust-032358bd30d2eaa31cdec4a40d8a4703fbec22cc.zip | |
Rollup merge of #95962 - sourcefrog:doc-direntry, r=Dylan-DPC
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.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/fs.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 10c424269c7..433b4d53013 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -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); |
