We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec565f6 commit ff668ecCopy full SHA for ff668ec
library/core/src/str/iter.rs
@@ -135,11 +135,7 @@ impl<'a> DoubleEndedIterator for Chars<'a> {
135
#[unstable(feature = "peekable_iterator", issue = "132973")]
136
impl<'a> PeekableIterator for Chars<'a> {
137
fn peek_with<T>(&mut self, func: impl for<'b> FnOnce(Option<&'b Self::Item>) -> T) -> T {
138
- // SAFETY: `str` invariant says `self.iter` is a valid UTF-8 string and
139
- // the resulting `ch` is a valid Unicode Scalar Value.
140
- let tmp = unsafe {
141
- next_code_point(&mut self.iter.clone()).map(|ch| char::from_u32_unchecked(ch))
142
- };
+ let tmp = self.clone().next();
143
func(&tmp)
144
}
145
0 commit comments