UNNECESSARY_TRANSMUTES in rustc_lint::transmute - Rust
Description: The `unnecessary_transmutes` lint detects transmutations that have safer alternatives.

Skip to main content

## UNNECESSARY_TRANSMUTES

# Static UNNECESSARY_TRANSMUTES

Source

    pub static UNNECESSARY_TRANSMUTES: &Lint

Expand description

The `unnecessary_transmutes` lint detects transmutations that have safer alternatives.

#### §Example

    fn bytes_at_home(x: [u8; 4]) -> u32 {
      unsafe { std::mem::transmute(x) }
    }

{{produces}}

#### §Explanation

Using an explicit method is preferable over calls to `transmute` as they more clearly communicate the intent, are easier to review, and are less likely to accidentally result in unsoundness.