Skip to content

Commit

Permalink
std: Remove Option.or_{default,zero}
Browse files Browse the repository at this point in the history
These can be replaced with `Some(option.or_default())`.
  • Loading branch information
erickt committed Sep 18, 2013
1 parent 460021b commit 5ab843f
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,23 +467,14 @@ impl<T: Default> Option<T> {
None => Default::default()
}
}

/// Returns self or `Some`-wrapped default value
#[inline]
pub fn or_default(self) -> Option<T> {
match self {
None => Some(Default::default()),
x => x,
}
}
}

impl<T> Default for Option<T> {
#[inline]
fn default() -> Option<T> { None }
}

impl<T:Zero> Option<T> {
impl<T: Zero> Option<T> {
/// Returns the contained value or zero (for this type)
#[inline]
pub fn unwrap_or_zero(self) -> T {
Expand All @@ -492,15 +483,6 @@ impl<T:Zero> Option<T> {
None => Zero::zero()
}
}

/// Returns self or `Some`-wrapped zero value
#[inline]
pub fn or_zero(self) -> Option<T> {
match self {
None => Some(Zero::zero()),
x => x
}
}
}

/// An iterator that yields either one or zero elements
Expand Down

0 comments on commit 5ab843f

Please sign in to comment.