rspec/rules/S1751/rust/rule.adoc

35 lines
479 B
Plaintext
Raw Normal View History

2025-03-25 12:30:36 +00:00
== Why is this an issue?
2025-03-25 13:36:48 +01:00
include::../description.adoc[]
2025-03-25 12:30:36 +00:00
2025-03-25 13:36:48 +01:00
=== Noncompliant code example
2025-03-25 12:30:36 +00:00
[source,rust,diff-id=1,diff-type=noncompliant]
----
2025-03-25 13:36:48 +01:00
let mut x = 0;
loop {
x += 1;
if x == 1 {
return;
}
break;
}
2025-03-25 12:30:36 +00:00
----
2025-03-25 13:36:48 +01:00
=== Compliant solution
2025-03-25 12:30:36 +00:00
[source,rust,diff-id=1,diff-type=compliant]
----
2025-03-25 13:36:48 +01:00
let mut x = 0;
x += 1;
if x == 1 {
return;
}
2025-03-25 12:30:36 +00:00
----
2025-03-25 13:36:48 +01:00
== Resources
2025-03-25 12:30:36 +00:00
2025-03-25 13:36:48 +01:00
=== Documentation
2025-03-25 12:30:36 +00:00
2025-03-25 13:36:48 +01:00
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#never_loop