Find in a Vec the smallest f(x).unwrap() where f(x) is not None
1fn func(x: f64) -> Option<f64> {2 if x > 2.5 {3 Some(x + 100.0)4 } else {5 None6 }7}8fn main() {9 let vec = vec![6.0, 5.0, 4.0, 3.0, 2.0, 1.0];10 let min_odd = vec11 .iter()12 .filter_map(|x| func(*x))13 .min_by(|x, y| x.partial_cmp(&y).unwrap_or(std::cmp::Ordering::Equal));14
15 println!("{min_odd:?}");1 collapsed line
16}