Skip to content

Commit 5ab843f

Browse files
committed
std: Remove Option.or_{default,zero}
These can be replaced with `Some(option.or_default())`.
1 parent 460021b commit 5ab843f

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/libstd/option.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -467,23 +467,14 @@ impl<T: Default> Option<T> {
467467
None => Default::default()
468468
}
469469
}
470-
471-
/// Returns self or `Some`-wrapped default value
472-
#[inline]
473-
pub fn or_default(self) -> Option<T> {
474-
match self {
475-
None => Some(Default::default()),
476-
x => x,
477-
}
478-
}
479470
}
480471

481472
impl<T> Default for Option<T> {
482473
#[inline]
483474
fn default() -> Option<T> { None }
484475
}
485476

486-
impl<T:Zero> Option<T> {
477+
impl<T: Zero> Option<T> {
487478
/// Returns the contained value or zero (for this type)
488479
#[inline]
489480
pub fn unwrap_or_zero(self) -> T {
@@ -492,15 +483,6 @@ impl<T:Zero> Option<T> {
492483
None => Zero::zero()
493484
}
494485
}
495-
496-
/// Returns self or `Some`-wrapped zero value
497-
#[inline]
498-
pub fn or_zero(self) -> Option<T> {
499-
match self {
500-
None => Some(Zero::zero()),
501-
x => x
502-
}
503-
}
504486
}
505487

506488
/// An iterator that yields either one or zero elements

0 commit comments

Comments
 (0)