]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys_common/wtf8.rs
libcore: assume the input of `next_code_point` and `next_code_point_reverse` is UTF...
[rust.git] / library / std / src / sys_common / wtf8.rs
index 0629859bd9dcc15bc232b502366bf21512500ff7..6e29bc61454c85076260a5f6412702a790506f04 100644 (file)
@@ -809,7 +809,8 @@ impl<'a> Iterator for Wtf8CodePoints<'a> {
 
     #[inline]
     fn next(&mut self) -> Option<CodePoint> {
-        next_code_point(&mut self.bytes).map(|c| CodePoint { value: c })
+        // SAFETY: `self.bytes` has been created from a WTF-8 string
+        unsafe { next_code_point(&mut self.bytes).map(|c| CodePoint { value: c }) }
     }
 
     #[inline]