about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-08-27 07:45:55 +0200
committerGitHub <noreply@github.com>2025-08-27 07:45:55 +0200
commitbc9655a7c8da8b995d072716c59db15e1be2c4f7 (patch)
tree43f576ed96ec7a8bd9cb8c6955ab8a231d4cb848
parent7879cbbbfffc85bd7ecad79a623c618e608d98dc (diff)
parent0b4f9783f0e11df0a3bed7fdea0628ee4b31a6f3 (diff)
downloadrust-bc9655a7c8da8b995d072716c59db15e1be2c4f7.tar.gz
rust-bc9655a7c8da8b995d072716c59db15e1be2c4f7.zip
Rollup merge of #145290 - ntc2:patch-1, r=joshtriplett,tgross35
Improve std::fs::read_dir docs

Call out early that the results returned can differ across calls / aren't deterministic. This was already mentioned at the bottom of examples, but I think it's worth calling out early, since this caused at least one person (me!) great confusion.
-rw-r--r--library/std/src/fs.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 1ed4f2f9f0c..d9c9606fc1c 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -3036,6 +3036,9 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
 /// Entries for the current and parent directories (typically `.` and `..`) are
 /// skipped.
 ///
+/// The order in which `read_dir` returns entries can change between calls. If reproducible
+/// ordering is required, the entries should be explicitly sorted.
+///
 /// # Platform-specific behavior
 ///
 /// This function currently corresponds to the `opendir` function on Unix