File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1440,8 +1440,10 @@ impl<'a> Iterator for EncodeUtf16<'a> {
1440
1440
#[ inline]
1441
1441
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1442
1442
let len = self . chars . iter . len ( ) ;
1443
- // The highest bytes:code units ratio occurs for 3-byte sequences, so
1444
- // use this to determine the lower bound for the hint. The lowest
1443
+ // The highest bytes:code units ratio occurs for 3-byte sequences,
1444
+ // since a 4-byte sequence results in 2 code units. The lower bound
1445
+ // is therefore determined by assuming the remaining bytes contain as
1446
+ // many 3-byte sequences as possible. The highest bytes:code units
1445
1447
// ratio is for 1-byte sequences, so use this for the upper bound.
1446
1448
// `(len + 2)` can't overflow, because we know that the `slice::Iter`
1447
1449
// belongs to a slice in memory which has a maximum length of
You can’t perform that action at this time.
0 commit comments