std-method

Option::is_some and is_none

These queries borrow the Option and report its variant without extracting the inner value. Some(false) is still present. Expected stdout (not executed): true false Common mistake: Confusing a false payload with None.

Formal Syntax & Structure

rust syntaxrust
fn is_some(&self) -> bool; fn is_none(&self) -> bool

Working Example

Example Snippetrust
fn main() {    let flag = Some(false);    println!("{} {}", flag.is_some(), flag.is_none());}
Rust Reference