Skip to content

Commit

Permalink
Resolve mem_replace_with_default clippy lint
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`
      --> serde_derive/src/internals/receiver.rs:52:24
       |
    52 |         let segments = mem::replace(&mut path.segments, Punctuated::new());
       |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut path.segments)`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
       = note: `-W clippy::mem-replace-with-default` implied by `-W clippy::all`
       = help: to override `-W clippy::all` add `#[allow(clippy::mem_replace_with_default)]`
  • Loading branch information
dtolnay committed Mar 3, 2025
1 parent f0d1ae0 commit 1c96013
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion serde_derive/src/internals/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl ReplaceReceiver<'_> {

path.leading_colon = Some(**path.segments.pairs().next().unwrap().punct().unwrap());

let segments = mem::replace(&mut path.segments, Punctuated::new());
let segments = mem::take(&mut path.segments);
path.segments = segments.into_pairs().skip(1).collect();
}

Expand Down

0 comments on commit 1c96013

Please sign in to comment.