Skip to content

Commit 16c2400

Browse files
committed
Resolve clippy::mem_replace_with_default
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> src/helpers.rs:54:29 | 54 | for item in mem::replace(&mut items, Default::default()).iter() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut items)` | = note: `-D clippy::mem-replace-with-default` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
1 parent 168e876 commit 16c2400

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn try_resolve_did<'tcx>(tcx: TyCtxt<'tcx>, path: &[&str]) -> Option<DefId> {
5151
let mut path_it = path.iter().skip(1).peekable();
5252

5353
while let Some(segment) = path_it.next() {
54-
for item in mem::replace(&mut items, Default::default()).iter() {
54+
for item in mem::take(&mut items).iter() {
5555
if item.ident.name.as_str() == *segment {
5656
if path_it.peek().is_none() {
5757
return Some(item.res.def_id());

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
clippy::from_over_into,
1919
clippy::if_same_then_else,
2020
clippy::manual_map,
21-
clippy::mem_replace_with_default,
2221
clippy::needless_borrow,
2322
clippy::needless_lifetimes,
2423
clippy::needless_question_mark,

0 commit comments

Comments
 (0)