Rust

Rust

Made by DeepSource

Found transmute between an integer and a bool RS-E1025

Bug risk
Major

Transmuting integers to booleans is not guaranteed to work properly, and is likely undefined behaviour. That is, reinterpreting bytes of an integer as a boolean can result in an invalid in-memory representation of a bool, which can lead to hard-to-track bugs.

Bad practice

unsafe fn foo(x: u8) -> bool { // x is an integer
    std::mem::transmute(x)
}

Recommended

fn foo(x: u8) -> bool { // x is an integer
    x != 0
}