Skip to content

Commit

Permalink
Documentation and formatting changes for option.rs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hatahet committed Mar 17, 2014
1 parent ffe72e9 commit a198d54
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<T> Option<T> {
}
}

/// Returns the contained value or a default
/// Returns the contained value or a default.
#[inline]
pub fn unwrap_or(self, def: T) -> T {
match self {
Expand All @@ -158,7 +158,7 @@ impl<T> Option<T> {
}
}

/// Returns the contained value or computes it from a closure
/// Returns the contained value or computes it from a closure.
#[inline]
pub fn unwrap_or_else(self, f: || -> T) -> T {
match self {
Expand All @@ -183,7 +183,7 @@ impl<T> Option<T> {
match self { None => def, Some(t) => f(t) }
}

/// Apply a function to the contained value or do nothing.
/// Applies a function to the contained value or does nothing.
/// Returns true if the contained value was mutated.
pub fn mutate(&mut self, f: |T| -> T) -> bool {
if self.is_some() {
Expand All @@ -192,7 +192,7 @@ impl<T> Option<T> {
} else { false }
}

/// Apply a function to the contained value or set it to a default.
/// Applies a function to the contained value or sets it to a default.
/// Returns true if the contained value was mutated, or false if set to the default.
pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool {
if self.is_some() {
Expand All @@ -208,19 +208,19 @@ impl<T> Option<T> {
// Iterator constructors
/////////////////////////////////////////////////////////////////////////

/// Return an iterator over the possibly contained value
/// Returns an iterator over the possibly contained value.
#[inline]
pub fn iter<'r>(&'r self) -> Item<&'r T> {
Item{opt: self.as_ref()}
}

/// Return a mutable iterator over the possibly contained value
/// Returns a mutable iterator over the possibly contained value.
#[inline]
pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> {
Item{opt: self.as_mut()}
}

/// Return a consuming iterator over the possibly contained value
/// Returns a consuming iterator over the possibly contained value.
#[inline]
pub fn move_iter(self) -> Item<T> {
Item{opt: self}
Expand Down Expand Up @@ -264,15 +264,15 @@ impl<T> Option<T> {
pub fn or_else(self, f: || -> Option<T>) -> Option<T> {
match self {
Some(_) => self,
None => f(),
None => f()
}
}

/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////

/// Take the value out of the option, leaving a `None` in its place.
/// Takes the value out of the option, leaving a `None` in its place.
#[inline]
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None)
Expand All @@ -282,7 +282,7 @@ impl<T> Option<T> {
#[inline(always)]
pub fn filtered(self, f: |t: &T| -> bool) -> Option<T> {
match self {
Some(x) => if f(&x) {Some(x)} else {None},
Some(x) => if f(&x) { Some(x) } else { None },
None => None
}
}
Expand Down

16 comments on commit a198d54

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 17, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hatahet@a198d54

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 17, 2014

Choose a reason for hiding this comment

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

merging hatahet/rust/option_doc = a198d54 into auto

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 17, 2014

Choose a reason for hiding this comment

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

hatahet/rust/option_doc = a198d54 merged ok, testing candidate = 73bff987

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hatahet@a198d54

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

merging hatahet/rust/option_doc = a198d54 into auto

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

hatahet/rust/option_doc = a198d54 merged ok, testing candidate = 01c04943

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hatahet@a198d54

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

merging hatahet/rust/option_doc = a198d54 into auto

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

hatahet/rust/option_doc = a198d54 merged ok, testing candidate = d5f60879

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 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 a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hatahet@a198d54

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

merging hatahet/rust/option_doc = a198d54 into auto

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Choose a reason for hiding this comment

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

hatahet/rust/option_doc = a198d54 merged ok, testing candidate = c544eab9

@bors
Copy link
Contributor

@bors bors commented on a198d54 Mar 18, 2014

Please sign in to comment.