#![feature(const_if_match)]
pub const fn is_some(x: Option<u32>) -> bool {
if let Some(_) = x { true } else { false }
}
Checking playground v0.0.1 (/playground)
warning: redundant pattern matching, consider using `is_some()`
--> src/lib.rs:3:12
|
3 | if let Some(_) = x { true } else { false }
| -------^^^^^^^---- help: try this: `if x.is_some()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
However, Option::is_some is not const fn in nightly-2020-06-07, so it can't be used in const fn.
Version: 2020-06-07 0262de5
(Playground)
However,
Option::is_someis notconst fninnightly-2020-06-07, so it can't be used inconst fn.Version:
2020-06-07 0262de5(Playground)