E0512 - Error codes index
Description: Book listing all Rust error codes

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Error code E0512

Transmute with two differently sized types was attempted.

Erroneous code example:

    fn takes_u8(_: u8) {}

    fn main() {
        unsafe { takes_u8(::std::mem::transmute(0u16)); }
        // error: cannot transmute between types of different sizes,
        //        or dependently-sized types
    }

Please use types with same size or use the expected type directly. Example:

    fn takes_u8(_: u8) {}

    fn main() {
        unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
        // or:
        unsafe { takes_u8(0u8); } // ok!
    }