diff options
| author | Jubilee <workingjubilee@gmail.com> | 2025-06-24 19:45:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-24 19:45:30 -0700 |
| commit | d46903b2b65ec6ec53cb4d0cbe185ac9e35c93b5 (patch) | |
| tree | 25968b0cc6a7339587a501b05ebe784afde9d3e4 | |
| parent | f542909d1ceae371fe0e236e00276109522fa86d (diff) | |
| parent | 595e88ae7d3cca6b05b1dfb4c3cd3ed74a1a7861 (diff) | |
| download | rust-d46903b2b65ec6ec53cb4d0cbe185ac9e35c93b5.tar.gz rust-d46903b2b65ec6ec53cb4d0cbe185ac9e35c93b5.zip | |
Rollup merge of #142453 - ChrisDenton:fused, r=Amanieu
Windows: make `read_dir` stop iterating after the first error is encountered This also essentially makes the `ReadDir` iterator fused. Which I think is pretty much what people expect anyway. [`FindNextFileW`](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilew) doesn't document what happens if you call it after iteration ends or after an error so we're probably in implementation defined territory at that point.
| -rw-r--r-- | library/std/src/sys/fs/windows.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index a95709b4891..9b674a25165 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -132,6 +132,7 @@ impl Iterator for ReadDir { let mut wfd = mem::zeroed(); loop { if c::FindNextFileW(handle.0, &mut wfd) == 0 { + self.handle = None; match api::get_last_error() { WinError::NO_MORE_FILES => return None, WinError { code } => { |
