Skip to content

Commit a7d3637

Browse files
committed
Refactored iter and mut_iter
Replaced match by self.as_ref() and self.as_mut()
1 parent dcf320a commit a7d3637

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/libstd/option.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,13 @@ impl<T> Option<T> {
211211
/// Return an iterator over the possibly contained value
212212
#[inline]
213213
pub fn iter<'r>(&'r self) -> Item<&'r T> {
214-
match *self {
215-
Some(ref x) => Item{opt: Some(x)},
216-
None => Item{opt: None}
217-
}
214+
Item{opt: self.as_ref()}
218215
}
219216

220217
/// Return a mutable iterator over the possibly contained value
221218
#[inline]
222219
pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
223-
match *self {
224-
Some(ref mut x) => Item{opt: Some(x)},
225-
None => Item{opt: None}
226-
}
220+
Item{opt: self.as_mut()}
227221
}
228222

229223
/// Return a consuming iterator over the possibly contained value

0 commit comments

Comments
 (0)