diff --git a/src/doc/book/casting-between-types.md b/src/doc/book/casting-between-types.md index 7d03d2991abdc..7056a6c0f1708 100644 --- a/src/doc/book/casting-between-types.md +++ b/src/doc/book/casting-between-types.md @@ -165,10 +165,15 @@ Rust lets us: ```rust use std::mem; -unsafe { - let a = [0u8, 0u8, 0u8, 0u8]; - - let b = mem::transmute::<[u8; 4], u32>(a); +fn main() { + unsafe { + let a = [0u8, 1u8, 0u8, 0u8]; + let b = mem::transmute::<[u8; 4], u32>(a); + println!("{}", b); // 256 + // or, more concisely: + let c: u32 = mem::transmute(a); + println!("{}", c); // 256 + } } ```