-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
rust/library/std/src/sys_common/wtf8.rs
Lines 854 to 860 in 4d3ce2e
| fn size_hint(&self) -> (usize, Option<usize>) { | |
| let (low, high) = self.code_points.size_hint(); | |
| // every code point gets either one u16 or two u16, | |
| // so this iterator is between 1 or 2 times as | |
| // long as the underlying iterator. | |
| (low, high.and_then(|n| n.checked_mul(2))) | |
| } |
I haven't tested it, but, on Windows the following test should pass with the current code, demonstrating how size_hint is currently broken:
#[test]
fn test() {
let os_str: &OsStr = "\u{12345}".as_ref();
let mut iter = os_str.encode_wide();
iter.next().unwrap();
// at this point iter.code_points is empty and iter.extra is non-zero
assert_eq!((0, Some(0)), iter.size_hint());
// size_hint returned 0, yet we didn't reach the end:
iter.next().unwrap();
}Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.