Skip to content

Commit

Permalink
Refactored iter and mut_iter
Browse files Browse the repository at this point in the history
Replaced match by self.as_ref() and self.as_mut()
  • Loading branch information
aochagavia committed Mar 14, 2014
1 parent dcf320a commit a7d3637
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/libstd/option.rs
Expand Up @@ -211,19 +211,13 @@ impl<T> Option<T> {
/// 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
Expand Down

5 comments on commit a7d3637

@bors
Copy link
Contributor

@bors bors commented on a7d3637 Mar 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a7d3637 Mar 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging aochagavia/rust/Fix-comment = a7d3637 into auto

@bors
Copy link
Contributor

@bors bors commented on a7d3637 Mar 14, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aochagavia/rust/Fix-comment = a7d3637 merged ok, testing candidate = 76e0e26

@bors
Copy link
Contributor

@bors bors commented on a7d3637 Mar 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 76e0e26

Please sign in to comment.