These both seem to work, but is one more "idiomatic Rust"?
Do you only use "if let" if you actually want to access some variable from your Option?
if let None = cli.pattern.as_deref() {
println!("Didn't pass in any optional pattern");
}
if None == cli.pattern.as_deref() {
println!("Didn't pass in any optional pattern");
}
if cli.pattern.is_none() {
println!("Didn't pass in any optional pattern");
}
See the documentation for Option::is_none and Option::as_deref. The call to as_deref isn't needed as is can't possibly change whether the option is None or not (unless it panics etc.).
If is_none wasn't available, I would always go for an explicit match or if let None = opt because you can only compare None via == iff PartialEq is implemented.