Refactored iter and mut_iter

Replaced match by self.as_ref() and self.as_mut()
This commit is contained in:
aochagavia 2014-03-14 17:29:47 +01:00
parent dcf320a639
commit a7d3637f67

View file

@ -211,19 +211,13 @@ impl<T> Option<T> {
/// Return an iterator over the possibly contained value
#[inline]
pub fn iter<'r>(&'r self) -> Item<&'r T> {
match *self {
Some(ref x) => Item{opt: Some(x)},
None => Item{opt: None}
}
Item{opt: self.as_ref()}
}
/// Return a mutable iterator over the possibly contained value
#[inline]
pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
match *self {
Some(ref mut x) => Item{opt: Some(x)},
None => Item{opt: None}
}
Item{opt: self.as_mut()}
}
/// Return a consuming iterator over the possibly contained value