Refactored iter and mut_iter
Replaced match by self.as_ref() and self.as_mut()
This commit is contained in:
parent
dcf320a639
commit
a7d3637f67
1 changed files with 2 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue