diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a2eff0200b77709281f36ec7a9d5c8ea18e76d87..b27fd4098e167f7bca2be9923fa2a9370329f1e8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -777,15 +777,7 @@ pub fn xor(self, optb: Option) -> Option { #[inline] #[stable(feature = "option_entry", since = "1.20.0")] pub fn get_or_insert(&mut self, v: T) -> &mut T { - match *self { - None => *self = Some(v), - _ => (), - } - - match *self { - Some(ref mut v) => v, - None => unsafe { hint::unreachable_unchecked() }, - } + self.get_or_insert_with(|| v) } /// Inserts a value computed from `f` into the option if it is [`None`], then