どう書くの
if Optional型.is_none() {
return;
}
おまけ
どう書くかわからなくてこんな感じに書いてたら、
if let Some(_) = manager.get(msg.guild(&ctx.cache).await.unwrap().id) {
} else {
return;
}
コンパイラが教えてくれた
warning: redundant pattern matching, consider using `is_some()`
--> src/handler/mod.rs:25:16
|
25 | if let Some(_) = manager.get(msg.guild(&ctx.cache).await.unwrap().id) {
| -------^^^^^^^------------------------------------------------------- help: try this: `if manager.get(msg.guild(&ctx.cache).await.unwrap().id).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
warning: this boolean expression can be simplified
--> src/handler/mod.rs:25:12
|
25 | if !manager.get(msg.guild(&ctx.cache).await.unwrap().id).is_some() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `manager.get(msg.guild(&ctx.cache).await.unwrap().id).is_none()`
|
= note: `#[warn(clippy::nonminimal_bool)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool