// run-rustfix
#![warn(clippy::option_filter_map)]
#![allow(clippy::map_flatten)]

fn main() {
    let _ = Some(Some(1)).flatten();
    let _ = Some(Some(1)).flatten();
    let _ = Some(1).map(odds_out).flatten();
    let _ = Some(1).map(odds_out).flatten();

    let _ = vec![Some(1)].into_iter().flatten();
    let _ = vec![Some(1)].into_iter().flatten();
    let _ = vec![1]
        .into_iter()
        .map(odds_out)
        .flatten();
    let _ = vec![1]
        .into_iter()
        .map(odds_out)
        .flatten();
}

fn odds_out(x: i32) -> Option<i32> {
    if x % 2 == 0 { Some(x) } else { None }
}
