diff --git a/src/imp_std.rs b/src/imp_std.rs index 5761f01..b65e091 100644 --- a/src/imp_std.rs +++ b/src/imp_std.rs @@ -209,7 +209,7 @@ fn initialize_or_wait(queue: &AtomicPtr, mut init: Option<&mut dyn FnMut return; } (INCOMPLETE, None) | (RUNNING, _) => { - wait(&queue, curr_queue); + wait(queue, curr_queue); curr_queue = queue.load(Ordering::Acquire); } _ => debug_assert!(false), diff --git a/src/lib.rs b/src/lib.rs index c2061f8..00cdd89 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -638,7 +638,7 @@ pub mod unsync { /// cell = OnceCell::new(); /// ``` pub fn take(&mut self) -> Option { - mem::replace(self, Self::default()).into_inner() + mem::take(self).into_inner() } /// Consumes the `OnceCell`, returning the wrapped value. @@ -1163,7 +1163,7 @@ pub mod sync { /// cell = OnceCell::new(); /// ``` pub fn take(&mut self) -> Option { - mem::replace(self, Self::default()).into_inner() + mem::take(self).into_inner() } /// Consumes the `OnceCell`, returning the wrapped value. Returns diff --git a/src/race.rs b/src/race.rs index ee3d51a..fe36fa1 100644 --- a/src/race.rs +++ b/src/race.rs @@ -351,7 +351,7 @@ mod once_box { Ordering::AcqRel, Ordering::Acquire, ); - if let Err(_) = exchange { + if exchange.is_err() { let value = unsafe { Box::from_raw(ptr) }; return Err(value); }