From 885ab76c0174bcd071e59624117f2d39f90b031a Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 22 May 2023 21:25:22 -0400 Subject: [PATCH] clippy::mem_replace_with_default warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> src/lib.rs:641:13 | 641 | mem::replace(self, Self::default()).into_inner() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default = note: `#[warn(clippy::mem_replace_with_default)]` on by default warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> src/lib.rs:1166:13 | 1166 | mem::replace(self, Self::default()).into_inner() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(self)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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