Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Mar 7, 2017
1 parent 6dbd754 commit d30aa66
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 36 deletions.
12 changes: 2 additions & 10 deletions core/src/stable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ impl AtomicUsize {
_: Ordering)
-> Result<usize, usize> {
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,
Expand All @@ -76,10 +72,6 @@ impl AtomicUsize {
_: Ordering)
-> Result<usize, usize> {
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) }
}
}
20 changes: 5 additions & 15 deletions src/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
});

Expand Down
8 changes: 5 additions & 3 deletions src/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
14 changes: 6 additions & 8 deletions src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d30aa66

Please sign in to comment.