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
|
/// Return an iterator over the possibly contained value
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter<'r>(&'r self) -> Item<&'r T> {
|
pub fn iter<'r>(&'r self) -> Item<&'r T> {
|
||||||
match *self {
|
Item{opt: self.as_ref()}
|
||||||
Some(ref x) => Item{opt: Some(x)},
|
|
||||||
None => Item{opt: None}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a mutable iterator over the possibly contained value
|
/// Return a mutable iterator over the possibly contained value
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
|
pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
|
||||||
match *self {
|
Item{opt: self.as_mut()}
|
||||||
Some(ref mut x) => Item{opt: Some(x)},
|
|
||||||
None => Item{opt: None}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a consuming iterator over the possibly contained value
|
/// Return a consuming iterator over the possibly contained value
|
||||||
|
|
Loading…
Reference in a new issue