Skip to content

Commit

Permalink
Implement Iterator for OwningRefMut
Browse files Browse the repository at this point in the history
  • Loading branch information
panicbit committed Jun 3, 2016
1 parent 44c831b commit b764120
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/incubation/owning_ref_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::ops::{Deref, DerefMut};
/// )
/// }
///
/// let items: Vec<_> = demo().by_ref().collect();
/// let items: Vec<_> = demo().collect();
/// assert_eq!(items, [2, 4, 6]);
/// ```

Expand Down Expand Up @@ -60,3 +60,10 @@ impl <T, R> DerefMut for OwningRefMut<T, R> {
self.borrow.as_mut().unwrap()
}
}

impl <T, R: Iterator<Item=U>, U> Iterator for OwningRefMut<T, R> {
type Item = U;
fn next(&mut self) -> Option<Self::Item> {
self.deref_mut().next()
}
}

0 comments on commit b764120

Please sign in to comment.