Update rule.adoc
This commit is contained in:
parent
3776dc517b
commit
2b290d6865
@ -1,44 +1,26 @@
|
|||||||
FIXME: add a description
|
|
||||||
|
|
||||||
// If you want to factorize the description uncomment the following line and create the file.
|
|
||||||
//include::../description.adoc[]
|
|
||||||
|
|
||||||
== Why is this an issue?
|
== Why is this an issue?
|
||||||
|
Using `.skip(0)` on an iterator does nothing, which is likely to be a mistake. It is more probable that `.skip(1)` was intended to skip the first element, or if not, the `.skip(0)` call should be removed to avoid confusion and make the code clearer.
|
||||||
|
|
||||||
FIXME: remove the unused optional headers (that are commented out)
|
|
||||||
|
|
||||||
//=== What is the potential impact?
|
|
||||||
|
|
||||||
== How to fix it
|
|
||||||
//== How to fix it in FRAMEWORK NAME
|
|
||||||
|
|
||||||
=== Code examples
|
=== Code examples
|
||||||
|
|
||||||
==== Noncompliant code example
|
==== Noncompliant code example
|
||||||
|
|
||||||
[source,rust,diff-id=1,diff-type=noncompliant]
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
||||||
----
|
----
|
||||||
FIXME
|
let v = vec![1, 2, 3];
|
||||||
|
let x = v.iter().skip(0).collect::<Vec<_>>(); // Noncompliant: .skip(0) does nothing
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Compliant solution
|
==== Compliant solution
|
||||||
|
|
||||||
[source,rust,diff-id=1,diff-type=compliant]
|
[source,rust,diff-id=1,diff-type=compliant]
|
||||||
----
|
----
|
||||||
FIXME
|
let v = vec![1, 2, 3];
|
||||||
|
let x = v.iter().collect::<Vec<_>>(); // Compliant: No .skip(0) call makes the intent clear
|
||||||
----
|
----
|
||||||
|
|
||||||
//=== How does this work?
|
== Resources
|
||||||
|
=== Documentation
|
||||||
|
|
||||||
//=== Pitfalls
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_zero
|
||||||
|
|
||||||
//=== Going the extra mile
|
|
||||||
|
|
||||||
|
|
||||||
//== Resources
|
|
||||||
//=== Documentation
|
|
||||||
//=== Articles & blog posts
|
|
||||||
//=== Conference presentations
|
|
||||||
//=== Standards
|
|
||||||
//=== External coding guidelines
|
|
||||||
//=== Benchmarks
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user