Function streaming_iterator::convert_mut
source · pub fn convert_mut<'a, I, T: ?Sized>(
iterator: I
) -> ConvertMut<'a, I::IntoIter, T>where
I: IntoIterator<Item = &'a mut T>,
Expand description
Turns an iterator of mutable references into a streaming iterator.
let mut scores = vec![Some(100), None, Some(80)];
{
let mut streaming_iter = convert_mut(&mut scores);
while let Some(opt_score) = streaming_iter.next_mut() {
if let Some(score) = opt_score.take() {
println!("The score is: {}", score);
}
// else already reported
}
}
assert_eq!(scores, [None, None, None]);