From d30aa66147dd5d3454e7d81b0c64dc04de288968 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 8 Mar 2017 00:39:35 +0100 Subject: [PATCH] Rustfmt --- core/src/stable.rs | 12 ++---------- src/once.rs | 20 +++++--------------- src/remutex.rs | 8 +++++--- src/rwlock.rs | 14 ++++++-------- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/core/src/stable.rs b/core/src/stable.rs index db35686b..11af7476 100644 --- a/core/src/stable.rs +++ b/core/src/stable.rs @@ -62,11 +62,7 @@ impl AtomicUsize { _: Ordering) -> Result { let res = self.0.compare_and_swap(old, new, order); - if res == old { - Ok(res) - } else { - Err(res) - } + if res == old { Ok(res) } else { Err(res) } } #[inline] pub fn compare_exchange_weak(&self, @@ -76,10 +72,6 @@ impl AtomicUsize { _: Ordering) -> Result { let res = self.0.compare_and_swap(old, new, order); - if res == old { - Ok(res) - } else { - Err(res) - } + if res == old { Ok(res) } else { Err(res) } } } diff --git a/src/once.rs b/src/once.rs index c6e38cb1..15135295 100644 --- a/src/once.rs +++ b/src/once.rs @@ -204,9 +204,7 @@ impl Once { let mut f = Some(f); self.call_once_slow(true, - &mut |state| unsafe { - f.take().unchecked_unwrap()(state) - }); + &mut |state| unsafe { f.take().unchecked_unwrap()(state) }); } // This is a non-generic function to reduce the monomorphization cost of @@ -397,15 +395,11 @@ mod tests { static O: Once = ONCE_INIT; // poison the once - let t = panic::catch_unwind(|| { - O.call_once(|| panic!()); - }); + let t = panic::catch_unwind(|| { O.call_once(|| panic!()); }); assert!(t.is_err()); // poisoning propagates - let t = panic::catch_unwind(|| { - O.call_once(|| {}); - }); + let t = panic::catch_unwind(|| { O.call_once(|| {}); }); assert!(t.is_err()); // we can subvert poisoning, however @@ -426,9 +420,7 @@ mod tests { static O: Once = ONCE_INIT; // poison the once - let t = panic::catch_unwind(|| { - O.call_once(|| panic!()); - }); + let t = panic::catch_unwind(|| { O.call_once(|| panic!()); }); assert!(t.is_err()); // make sure someone's waiting inside the once via a force @@ -447,9 +439,7 @@ mod tests { // put another waiter on the once let t2 = thread::spawn(|| { let mut called = false; - O.call_once(|| { - called = true; - }); + O.call_once(|| { called = true; }); assert!(!called); }); diff --git a/src/remutex.rs b/src/remutex.rs index f8ed78c6..8d46a0bd 100644 --- a/src/remutex.rs +++ b/src/remutex.rs @@ -308,9 +308,11 @@ mod tests { let _lock = m.try_lock(); let _lock2 = m.try_lock(); thread::spawn(move || { - let lock = m2.try_lock(); - assert!(lock.is_none()); - }).join().unwrap(); + let lock = m2.try_lock(); + assert!(lock.is_none()); + }) + .join() + .unwrap(); let _lock3 = m.try_lock(); } } diff --git a/src/rwlock.rs b/src/rwlock.rs index 582e6618..0eadefc8 100644 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -788,14 +788,12 @@ mod tests { let mut handles = Vec::new(); for _ in 0..8 { let x = x.clone(); - handles.push(thread::spawn(move || { - for _ in 0..100 { - let mut writer = x.write(); - *writer += 1; - let cur_val = *writer; - let reader = writer.downgrade(); - assert_eq!(cur_val, *reader); - } + handles.push(thread::spawn(move || for _ in 0..100 { + let mut writer = x.write(); + *writer += 1; + let cur_val = *writer; + let reader = writer.downgrade(); + assert_eq!(cur_val, *reader); })); } for handle in handles {