50 lines
857 B
Plaintext
50 lines
857 B
Plaintext
![]() |
== Why is this an issue?
|
||
|
|
||
|
include::../description.adoc[]
|
||
|
|
||
|
=== Code examples
|
||
|
|
||
|
==== Noncompliant code example
|
||
|
|
||
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
||
|
----
|
||
|
fn main() {
|
||
|
let x = 5;
|
||
|
|
||
|
if x > 0 {
|
||
|
println!("x is positive");
|
||
|
}; // Noncompliant
|
||
|
|
||
|
match x {
|
||
|
1 => println!("x is one"),
|
||
|
2 => println!("x is two"),
|
||
|
_ => println!("x is something else"),
|
||
|
}; // Noncompliant
|
||
|
}
|
||
|
----
|
||
|
|
||
|
==== Compliant solution
|
||
|
|
||
|
[source,rust,diff-id=1,diff-type=compliant]
|
||
|
----
|
||
|
fn main() {
|
||
|
let x = 5;
|
||
|
|
||
|
if x > 0 {
|
||
|
println!("x is positive");
|
||
|
}
|
||
|
|
||
|
match x {
|
||
|
1 => println!("x is one"),
|
||
|
2 => println!("x is two"),
|
||
|
_ => println!("x is something else"),
|
||
|
}
|
||
|
}
|
||
|
----
|
||
|
|
||
|
== Resources
|
||
|
|
||
|
=== Documentation
|
||
|
|
||
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon
|