You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fncopy(arr:&mut[u8],from:usize,target:&[u8]){for i in from..from + target.len(){
arr[i] = target[i - from];}}
triggers this warning:
warning: it looks like you're manually copying between slices
--> src/main.rs:2:14
|
2 | for i in from..from + target.len(){
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `arr[from..from + target.len()].clone_from_slice(&target[(from - from)..(from + target.len() - from)])`
|
= note: #[warn(manual_memcpy)] on by default
= help:for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#manual_memcpy
But this contains (from - from), which by itself leads to next error:
error: equal expressions asoperands to `-`
--> src/main.rs:3:35
|
3 | .clone_from_slice(&target[(from - from)..(from + target.len() - from)])
| ^^^^^^^^^^^^^
|
= note: #[deny(eq_op)] on by default
= help:for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#eq_op
In the case of copying the entire slice clippy may provide specialized suggestion
warning: it looks like you're manually copying between slices
--> src/main.rs:2:14
|
2 | for i in from..from + target.len(){
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `arr[from..from + target.len()].clone_from_slice(&target)`
|
The text was updated successfully, but these errors were encountered:
Following code:
triggers this warning:
But this contains
(from - from)
, which by itself leads to next error:In the case of copying the entire slice
clippy
may provide specialized suggestionThe text was updated successfully, but these errors were encountered: