RS.CLIPPY.TRANSMUTE_INT_TO_BOOL

Transmutes from an integer to a `bool`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: transmute_int_to_bool. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for transmutes from an integer to a bool.

Why is this bad?

This might result in an invalid in-memory representation of a bool.

Example

let x = 1_u8;
unsafe {
    let _: bool = std::mem::transmute(x); // where x: u8
}

// should be:
let _: bool = x != 0;