]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/option.rs
auto merge of #12888 : aochagavia/rust/Fix-comment, r=alexcrichton
[rust.git] / src / libstd / option.rs
index 2a0071526b85685023833c8e2ece3fbd850d04e1..b70c8e172599886bc439554ff1e41167de51bf05 100644 (file)
@@ -104,7 +104,7 @@ pub fn as_slice<'r>(&'r self) -> &'r [T] {
         }
     }
 
-    /// 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 {
@@ -211,19 +211,13 @@ pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool {
     /// 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