Chained if statements in rust?

Solution 1:

You can map the operation before, and then match it fully:

if matches!(x.map(|y| y.pow(2)), Some(49)) {
    println!("Yeah");
}

Or using ==:

if x.map(|y| y.pow(2)) ==  Some(49) {
    println!("Yeah");
}

Playground