Skip to content

Commit

Permalink
style: Replace unnecessary map_or
Browse files Browse the repository at this point in the history
Fixes clippy lints like this:
```
warning: this `map_or` is redundant
   --> prost-build/src/ast.rs:104:9
    |
104 | /         chars
105 | |             .next()
106 | |             .map_or(false, |c| c != ' ' || chars.next() == Some(' '))
    | |_____________________________________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `#[warn(clippy::unnecessary_map_or)]` on by default
```
  • Loading branch information
caspermeijn committed Jan 3, 2025
1 parent 68cf18a commit 42ad76a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion prost-build/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Comments {
let mut chars = sanitized_line.chars();
chars
.next()
.map_or(false, |c| c != ' ' || chars.next() == Some(' '))
.is_some_and(|c| c != ' ' || chars.next() == Some(' '))
}

/// Sanitizes the line for rustdoc by performing the following operations:
Expand Down
4 changes: 2 additions & 2 deletions prost-build/src/code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl CodeGenerator<'_> {
// If no package is specified the start of the package name will be '.'
// and split will return an empty string ("") which breaks resolution
// The fix to this is to ignore the first item if it is empty.
if local_path.peek().map_or(false, |s| s.is_empty()) {
if local_path.peek().is_some_and(|s| s.is_empty()) {
local_path.next();
}

Expand Down Expand Up @@ -1106,7 +1106,7 @@ impl CodeGenerator<'_> {
field
.options
.as_ref()
.map_or(false, FieldOptions::deprecated)
.is_some_and(FieldOptions::deprecated)
}

/// Returns the fully-qualified name, starting with a dot
Expand Down

0 comments on commit 42ad76a

Please sign in to comment.