Skip to content

Commit bedbf3b

Browse files
committed
Apply clippy::single_match suggestion
1 parent 7491468 commit bedbf3b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/libcore/option.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,8 @@ impl<T> Option<T> {
837837
#[inline]
838838
#[stable(feature = "option_entry", since = "1.20.0")]
839839
pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
840-
match *self {
841-
None => *self = Some(f()),
842-
_ => (),
840+
if let None = *self {
841+
*self = Some(f());
843842
}
844843

845844
match *self {

src/libstd/thread/local.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,8 @@ pub mod os {
509509
pub unsafe fn get(&'static self, init: fn() -> T) -> Option<&'static T> {
510510
let ptr = self.os.get() as *mut Value<T>;
511511
if ptr as usize > 1 {
512-
match (*ptr).inner.get() {
513-
Some(ref value) => return Some(value),
514-
None => {},
512+
if let Some(ref value) = (*ptr).inner.get() {
513+
return Some(value);
515514
}
516515
}
517516
self.try_initialize(init)

0 commit comments

Comments
 (0)