What it does
Lints for example this code:
let array: [u8; 4] = [1, 2, 3, 4];
let slice: &[u8] = &array[..];
and suggests array::as_slice:
let array: [u8; 4] = [1, 2, 3, 4];
let slice: &[u8] = array.as_slice();
(same should be suggested for &mut array[..], which can be replaced with array.as_mut_slice())
Categories (optional)
- Kind:
clippy::pedantic or clippy::style
What is the advantage of the recommended code over the original code?
For example:
Drawbacks
- might have a lot of false positives or not much benefit in using the function
Possibly related issues:
Stabilization
At the time of writing this issue, the function is still unstable, but with the merging of rust-lang/rust#88353, this feature will be stabilized. (final-comment-period, so will be merged in the next few days)
What it does
Lints for example this code:
and suggests
array::as_slice:(same should be suggested for
&mut array[..], which can be replaced witharray.as_mut_slice())Categories (optional)
clippy::pedanticorclippy::styleWhat is the advantage of the recommended code over the original code?
For example:
[..]does)array::as_sliceexists? (see Add[T; N]::as_[mut_]slicerust#76120)Drawbacks
Possibly related issues:
as_slicewill be stable in 1.7 #728&[char]#5598Stabilization
At the time of writing this issue, the function is still unstable, but with the merging of rust-lang/rust#88353, this feature will be stabilized. (final-comment-period, so will be merged in the next few days)