]> git.proxmox.com Git - rustc.git/blobdiff - library/std/src/sys_common/wtf8.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / library / std / src / sys_common / wtf8.rs
index 7d4b0d5283199012a23425cd3afd50d7591e0ba7..1bd3cfd2200ffb2935882acbe213c4d298aced38 100644 (file)
@@ -853,10 +853,11 @@ impl<'a> Iterator for EncodeWide<'a> {
     #[inline]
     fn size_hint(&self) -> (usize, Option<usize>) {
         let (low, high) = self.code_points.size_hint();
+        let ext = (self.extra != 0) as usize;
         // 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)))
+        (low + ext, high.and_then(|n| n.checked_mul(2)).and_then(|n| n.checked_add(ext)))
     }
 }