diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 86f8c143a9e99..49d40605c268d 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -104,7 +104,7 @@ impl Option { } } - /// Convert from `Option` to `&[T]` (without copying) + /// Convert from `Option` to `&mut [T]` (without copying) #[inline] pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { match *self { @@ -211,19 +211,13 @@ impl Option { /// 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