Skip to content

Commit a11f5f2

Browse files
committed
Resolve unnecessary_map_or clippy lints
warning: this `map_or` is redundant --> src/value/partial_eq.rs:5:5 | 5 | value.as_i64().map_or(false, |i| i == other) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(value.as_i64() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `-W clippy::unnecessary-map-or` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::unnecessary_map_or)]` warning: this `map_or` is redundant --> src/value/partial_eq.rs:9:5 | 9 | value.as_u64().map_or(false, |i| i == other) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(value.as_u64() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or warning: this `map_or` is redundant --> src/value/partial_eq.rs:14:29 | 14 | Value::Number(n) => n.as_f32().map_or(false, |i| i == other), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(n.as_f32() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or warning: this `map_or` is redundant --> src/value/partial_eq.rs:20:5 | 20 | value.as_f64().map_or(false, |i| i == other) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(value.as_f64() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or warning: this `map_or` is redundant --> src/value/partial_eq.rs:24:5 | 24 | value.as_bool().map_or(false, |i| i == other) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(value.as_bool() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or warning: this `map_or` is redundant --> src/value/partial_eq.rs:28:5 | 28 | value.as_str().map_or(false, |i| i == other) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a standard comparison instead: `(value.as_str() == Some(other))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
1 parent 07f280a commit a11f5f2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/value/partial_eq.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ use super::Value;
22
use alloc::string::String;
33

44
fn eq_i64(value: &Value, other: i64) -> bool {
5-
value.as_i64().map_or(false, |i| i == other)
5+
value.as_i64() == Some(other)
66
}
77

88
fn eq_u64(value: &Value, other: u64) -> bool {
9-
value.as_u64().map_or(false, |i| i == other)
9+
value.as_u64() == Some(other)
1010
}
1111

1212
fn eq_f32(value: &Value, other: f32) -> bool {
1313
match value {
14-
Value::Number(n) => n.as_f32().map_or(false, |i| i == other),
14+
Value::Number(n) => n.as_f32() == Some(other),
1515
_ => false,
1616
}
1717
}
1818

1919
fn eq_f64(value: &Value, other: f64) -> bool {
20-
value.as_f64().map_or(false, |i| i == other)
20+
value.as_f64() == Some(other)
2121
}
2222

2323
fn eq_bool(value: &Value, other: bool) -> bool {
24-
value.as_bool().map_or(false, |i| i == other)
24+
value.as_bool() == Some(other)
2525
}
2626

2727
fn eq_str(value: &Value, other: &str) -> bool {
28-
value.as_str().map_or(false, |i| i == other)
28+
value.as_str() == Some(other)
2929
}
3030

3131
impl PartialEq<str> for Value {

0 commit comments

Comments
 (0)