We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inspired by this issue: rust-lang/rust#91625
In code like this:
fn main() { let s = "abc".to_string(); let t = s.strip_prefix(&['a', 'x'][..]); println!("{:?}", t); }
Clippy could suggest to write instead:
s.strip_prefix(&['a', 'x'])
Or even:
s.strip_prefix(['a', 'x'])
No response
<code>
Could be written as:
The text was updated successfully, but these errors were encountered:
Another example where there should be a lint:
fn foo(_v: &[u8]) {} fn main() { let v = vec![1, 2, 3, 4]; foo(&v[..]); }
Sorry, something went wrong.
We have the redundant_slicing lint, so it would be better to improve this.
redundant_slicing
Clippy could suggest to write instead: s.strip_prefix(&['a', 'x'])
It causes a compile error with currently stable 1.57.0, not beta and nightly.
FTR, this doesn't trigger the lint either:
#![forbid(clippy::redundant_slicing)] fn foo(_v: &[u8]) {} fn main() { foo(&[1, 2, 3, 4][..]); }
And the version without the [..] compiles on stable.
[..]
No branches or pull requests
What it does
Inspired by this issue:
rust-lang/rust#91625
In code like this:
Clippy could suggest to write instead:
Or even:
Lint Name
No response
Category
No response
Advantage
No response
Drawbacks
No response
Example
<code>
Could be written as:
<code>
The text was updated successfully, but these errors were encountered: