We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bea5cd1 commit fa5e283Copy full SHA for fa5e283
library/core/src/char/decode.rs
@@ -122,7 +122,12 @@ impl<I: Iterator<Item = u16>> Iterator for DecodeUtf16<I> {
122
let (low, high) = self.iter.size_hint();
123
// we could be entirely valid surrogates (2 elements per
124
// char), or entirely non-surrogates (1 element per char)
125
- (low.div_ceil(2), high)
+ //
126
+ // In addition to `self.iter`, there's potentially one
127
+ // additional number in `self.buf`.
128
+ // On odd lower bound, at least one element must stay unpaired
129
+ // (with other elements from `self.iter`).
130
+ (low.div_ceil(2), try { high?.checked_add(1)? })
131
}
132
133
0 commit comments