Skip to content

Commit 506a770

Browse files
authored
Rollup merge of rust-lang#96397 - AronParker:issue-96368-fix, r=dtolnay
Make EncodeWide implement FusedIterator [`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr. When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose. This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance. Fixes rust-lang#96368
2 parents 0076a91 + fc6af81 commit 506a770

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/sys_common/wtf8.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::char;
2525
use crate::collections::TryReserveError;
2626
use crate::fmt;
2727
use crate::hash::{Hash, Hasher};
28-
use crate::iter::FromIterator;
28+
use crate::iter::{FromIterator, FusedIterator};
2929
use crate::mem;
3030
use crate::ops;
3131
use crate::rc::Rc;
@@ -899,6 +899,9 @@ impl<'a> Iterator for EncodeWide<'a> {
899899
}
900900
}
901901

902+
#[stable(feature = "encode_wide_fused_iterator", since = "1.62.0")]
903+
impl FusedIterator for EncodeWide<'_> {}
904+
902905
impl Hash for CodePoint {
903906
#[inline]
904907
fn hash<H: Hasher>(&self, state: &mut H) {

0 commit comments

Comments
 (0)