Rust

Rust

Made by DeepSource

Found assertion on boolean constant RS-W1021

Anti-pattern
Minor
Autofix

Assertions on true are optimized out by the compiler and can be removed safely. Asserting false will always result in a panic, prefer using panic!() or unreachable!() with a meaningful message.

Remove statements of the form assert!(true) and replace statements of the form assert!(false) with panic!(), with a meaningful message.

Bad practice

if condition {
    // ...
} else {
    // unreachable
    assert!(false);
}

Recommended

if condition {
    // ...
} else {
    // unreachable
    panic!("Hit unreachable condition!");
}