Use positive if condition for readability

This commit is contained in:
Philipp Hansch 2019-02-28 07:00:22 +01:00
parent 2851f9f707
commit 9ff1340a69
No known key found for this signature in database
GPG Key ID: B6FA06A6E0E2665B

View File

@ -228,14 +228,15 @@ With that we can expand our `check_fn` method to:
```rust
impl EarlyLintPass for Pass {
fn check_fn(&mut self, cx: &EarlyContext<'_>, fn_kind: FnKind<'_>, _: &FnDecl, span: Span, _: NodeId) {
if !is_foo_fn(fn_kind) { return; }
span_help_and_lint(
cx,
FOO_FUNCTIONS,
span,
"function named `foo`",
"consider using a more meaningful name"
);
if is_foo_fn(fn_kind) {
span_help_and_lint(
cx,
FOO_FUNCTIONS,
span,
"function named `foo`",
"consider using a more meaningful name"
);
}
}
}
```