diff --git a/src/peeking_take_while.rs b/src/peeking_take_while.rs index f830b7162..e828b717d 100644 --- a/src/peeking_take_while.rs +++ b/src/peeking_take_while.rs @@ -92,6 +92,57 @@ where } } +#[cfg(feature = "use_alloc")] +impl PeekingNext for ::alloc::vec::IntoIter { + fn peeking_next(&mut self, accept: F) -> Option + where + F: FnOnce(&Self::Item) -> bool, + { + match accept(self.as_slice().first()?) { + true => self.next(), + false => None, + } + } +} + +#[cfg(feature = "use_alloc")] +impl<'a, T> PeekingNext for ::alloc::vec::Drain<'a, T> { + fn peeking_next(&mut self, accept: F) -> Option + where + F: FnOnce(&Self::Item) -> bool, + { + match accept(self.as_slice().first()?) { + true => self.next(), + false => None, + } + } +} + +#[cfg(feature = "use_alloc")] +impl<'a> PeekingNext for ::alloc::string::Drain<'a> { + fn peeking_next(&mut self, accept: F) -> Option + where + F: FnOnce(&Self::Item) -> bool, + { + match accept(&self.as_str().chars().next()?) { + true => self.next(), + false => None, + } + } +} + +impl PeekingNext for ::core::array::IntoIter { + fn peeking_next(&mut self, accept: F) -> Option + where + F: FnOnce(&Self::Item) -> bool, + { + match accept(self.as_slice().first()?) { + true => self.next(), + false => None, + } + } +} + impl PeekingNext for RepeatN { fn peeking_next(&mut self, accept: F) -> Option where