Skip to content

Commit d46903b

Browse files
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.
2 parents f542909 + 595e88a commit d46903b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/std/src/sys/fs/windows.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl Iterator for ReadDir {
132132
let mut wfd = mem::zeroed();
133133
loop {
134134
if c::FindNextFileW(handle.0, &mut wfd) == 0 {
135+
self.handle = None;
135136
match api::get_last_error() {
136137
WinError::NO_MORE_FILES => return None,
137138
WinError { code } => {

0 commit comments

Comments
 (0)