}
}
- /// Convert from `Option<T>` to `&[T]` (without copying)
+ /// Convert from `Option<T>` to `&mut [T]` (without copying)
#[inline]
pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
match *self {
/// 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