Commit 43990c4
committed
coord: ranged1d: fix irrefutable if let warning
I keep getting this annoying warning with rust 1.83:
warning: irrefutable `if let` pattern
--> plotters/src/coord/ranged1d/types/numeric.rs:29:20
|
29 | if let Ok(index) = Self::ValueType::try_from(index) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
365 | impl_discrete_trait!(RangedCoordusize);
| -------------------------------------- in this macro invocation
|
= note: this pattern will always match, so the `if let` is useless
= help: consider replacing the `if let` with a `let`
= note: `#[warn(irrefutable_let_patterns)]` on by default
= note: this warning originates in the macro `impl_discrete_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
This is because the conversion of usize to ValueType always
passes, so we don't need the try_from().
The problem with this operation is not the conversion which
always succeeds, instead it is the potential overflows, so we
use checked_add() which returns None if the addition fails.
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>1 parent 3ad52da commit 43990c4
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
| |||
0 commit comments