Add manual_memcpy_test
for VecDeque
This commit is contained in:
parent
3925def9cf
commit
062db10c12
@ -113,6 +113,17 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) {
|
||||
for i in 0.. {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
// VecDeque - ideally this would work, but would require something like `range_as_slices`
|
||||
let mut dst = std::collections::VecDeque::from_iter([0; 5]);
|
||||
let src = std::collections::VecDeque::from_iter([0, 1, 2, 3, 4]);
|
||||
for i in 0..dst.len() {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
let src = vec![0, 1, 2, 3, 4];
|
||||
for i in 0..dst.len() {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
#[warn(clippy::needless_range_loop, clippy::manual_memcpy)]
|
||||
|
@ -104,7 +104,7 @@ LL | | }
|
||||
| |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> $DIR/without_loop_counters.rs:120:5
|
||||
--> $DIR/without_loop_counters.rs:131:5
|
||||
|
|
||||
LL | / for i in 0..src.len() {
|
||||
LL | | dst[i] = src[i].clone();
|
||||
|
Loading…
x
Reference in New Issue
Block a user