Skip to content

Commit

Permalink
clippy::mem_replace_with_default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jqnatividad committed May 23, 2023
1 parent 3514863 commit 885ab76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ pub mod unsync {
/// cell = OnceCell::new();
/// ```
pub fn take(&mut self) -> Option<T> {
mem::replace(self, Self::default()).into_inner()
mem::take(self).into_inner()
}

/// Consumes the `OnceCell`, returning the wrapped value.
Expand Down Expand Up @@ -1163,7 +1163,7 @@ pub mod sync {
/// cell = OnceCell::new();
/// ```
pub fn take(&mut self) -> Option<T> {
mem::replace(self, Self::default()).into_inner()
mem::take(self).into_inner()
}

/// Consumes the `OnceCell`, returning the wrapped value. Returns
Expand Down

0 comments on commit 885ab76

Please sign in to comment.