Update rule.adoc
This commit is contained in:
parent
0b08f51c46
commit
4881d94421
@ -1,44 +1,28 @@
|
|||||||
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?
|
||||||
|
Calling `.step_by(0)` on an iterator will cause the program to panic. This is likely an oversight and should be corrected to ensure program stability. If the intent is to cause a panic, it is clearer to use `panic!()` directly.
|
||||||
|
|
||||||
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
|
for x in (0..100).step_by(0) { // Noncompliant: This will cause a panic.
|
||||||
|
// ...
|
||||||
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Compliant solution
|
==== Compliant solution
|
||||||
|
|
||||||
[source,rust,diff-id=1,diff-type=compliant]
|
[source,rust,diff-id=1,diff-type=compliant]
|
||||||
----
|
----
|
||||||
FIXME
|
for x in (0..100).step_by(1) { // Compliant: Step by a valid positive integer.
|
||||||
|
// ...
|
||||||
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
//=== How does this work?
|
== Resources
|
||||||
|
=== Documentation
|
||||||
|
|
||||||
//=== Pitfalls
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_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