mirror of
https://github.com/pezkuwichain/merkle-mountain-range.git
synced 2026-06-21 23:51:03 +00:00
clippy: Using mem::take is faster as it avoids the allocation: https://rust-lang.github.io/rust-clippy/master/index.html#drain_collect
cargo clippy --all --all-features --all-targets
warning: you seem to be trying to move all elements into a new `Vec`
--> src/mmr.rs:501:5
|
501 | v.drain(..).collect()
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(v)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#drain_collect
= note: `#[warn(clippy::drain_collect)]` on by default
Signed-off-by: Eval EXEC <execvy@gmail.com>
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@ use crate::vec::Vec;
|
||||
use crate::{Error, Merge, Result};
|
||||
use core::fmt::Debug;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem;
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct MMR<T, M, S> {
|
||||
@@ -498,5 +499,5 @@ fn take_while_vec<T, P: Fn(&T) -> bool>(v: &mut Vec<T>, p: P) -> Vec<T> {
|
||||
return v.drain(..i).collect();
|
||||
}
|
||||
}
|
||||
v.drain(..).collect()
|
||||
mem::take(v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user