Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting Docs.rs doc conflict with a clippy lint #1723

Closed
Stargateur opened this issue Apr 15, 2022 · 0 comments · Fixed by #1724
Closed

Detecting Docs.rs doc conflict with a clippy lint #1723

Stargateur opened this issue Apr 15, 2022 · 0 comments · Fixed by #1724

Comments

@Stargateur
Copy link
Contributor

Stargateur commented Apr 15, 2022

Detecting Docs.rs give a code example:

if let Ok(_) = std::env::var("DOCS_RS") {
    // ... your code here ...
}

This generate a lint from clippy redundant_pattern_matching:

 error: redundant pattern matching, consider using `is_ok()`
  --> build.rs:43:12
   |
43 |     if let Ok(_) = std::env::var("DOCS_RS") {
   |     -------^^^^^--------------------------- help: try this: `if std::env::var("DOCS_RS").is_ok()`
   |
   = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching

I'm not a big fan of this lint cause I prefer the if let Ok(_) style but that still a default lint of clippy for now so maybe doc should reflect clippy advice.

if std::env::var("DOCS_RS").is_ok() {
    // ... your code here ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant