Skip to content

Commit f53020f

Browse files
committed
style: Replace unnecessary map_or
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 ```
1 parent 68cf18a commit f53020f

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

prost-build/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Comments {
103103
let mut chars = sanitized_line.chars();
104104
chars
105105
.next()
106-
.map_or(false, |c| c != ' ' || chars.next() == Some(' '))
106+
.is_some_and(|c| c != ' ' || chars.next() == Some(' '))
107107
}
108108

109109
/// Sanitizes the line for rustdoc by performing the following operations:

prost-build/src/code_generator.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl CodeGenerator<'_> {
986986
// If no package is specified the start of the package name will be '.'
987987
// and split will return an empty string ("") which breaks resolution
988988
// The fix to this is to ignore the first item if it is empty.
989-
if local_path.peek().map_or(false, |s| s.is_empty()) {
989+
if local_path.peek().is_some_and(|s| s.is_empty()) {
990990
local_path.next();
991991
}
992992

@@ -1103,10 +1103,7 @@ impl CodeGenerator<'_> {
11031103

11041104
/// Returns `true` if the field options includes the `deprecated` option.
11051105
fn deprecated(&self, field: &FieldDescriptorProto) -> bool {
1106-
field
1107-
.options
1108-
.as_ref()
1109-
.map_or(false, FieldOptions::deprecated)
1106+
field.options.as_ref().is_some_and(FieldOptions::deprecated)
11101107
}
11111108

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

0 commit comments

Comments
 (0)