about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMartin Pool <mbp@google.com>2022-04-11 19:00:29 -0700
committerMartin Pool <mbp@google.com>2022-04-11 19:00:29 -0700
commit7cdef0876deb12e3a5a69c9dec2b386fa61a4384 (patch)
tree05800aa2d886028120d439b02ad915f7ed91d426 /library/std/src
parentde392c7d31602ddf0fae1143c5ad822a1abe89df (diff)
downloadrust-7cdef0876deb12e3a5a69c9dec2b386fa61a4384.tar.gz
rust-7cdef0876deb12e3a5a69c9dec2b386fa61a4384.zip
Document that DirEntry holds the directory open
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/fs.rs10
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);