{
type Item = (&'a mut [T], &'a mut [T], &'a mut T);
fn next(&mut self) -> Option<Self::Item> {
if self.index >= self.slice.len() {
return None;
}
let (left, right) = self.slice.split_at_mut(self.index);
let (value, right) = right.split_at_mut(1);
self.index += 1;
unsafe { std::mem::transmute(
Some((left, right, &mut value[0]))
)}
}
}
WithOuterIteratorMut покажи
pub struct WithOuterIteratorMut<'a, T> { slice: &'a mut [T], index: usize, }
https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=6e037cf083fa4efd1a17dddf7b87ce58]
Обсуждают сегодня