bool
RS-E1025Transmuting 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.
unsafe fn foo(x: u8) -> bool { // x is an integer
std::mem::transmute(x)
}
fn foo(x: u8) -> bool { // x is an integer
x != 0
}