std: Remove Option.or_{default,zero}
These can be replaced with `Some(option.or_default())`.
This commit is contained in:
parent
460021bdf2
commit
5ab843fbc3
@ -467,15 +467,6 @@ pub fn unwrap_or_default(self) -> 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> {
|
||||
@ -483,7 +474,7 @@ impl<T> Default for Option<T> {
|
||||
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 {
|
||||
@ -492,15 +483,6 @@ pub fn unwrap_or_zero(self) -> 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
|
||||
|
Loading…
Reference in New Issue
Block a user