#![warn(clippy::manual_take)]

fn main() {
    let mut x = true;
    let mut y = false;

    let _lint_negated = !std::mem::take(&mut x);

    let _ = if x {
        y = false;
        true
    } else {
        false
    };

    let _ = if x {
        x = true;
        true
    } else {
        false
    };

    let _ = if x {
        x = false;
        y = true;
        false
    } else {
        true
    };

    let _ = if x {
        x = false;
        false
    } else {
        y = true;
        true
    };
}

#[clippy::msrv = "1.39.0"]
fn msrv_1_39() -> bool {
    let mut x = true;
    if x {
        x = false;
        true
    } else {
        false
    }
}

#[clippy::msrv = "1.40.0"]
fn msrv_1_40() -> bool {
    let mut x = true;
    std::mem::take(&mut x)
}
