expression

Decode little-endian boundary data explicitly

WebAssembly numeric memory loads and stores use little-endian byte order. Specify byte order in an application protocol independently of the host language. This Rust example decodes a four-byte value without alignment or pointer assumptions. Expected host stdout (not executed): value: 4660 Common mistake: Reinterpreting arbitrary memory as a native struct without checking layout, bounds or alignment.

Formal Syntax & Structure

rust syntaxrust
u32::from_le_bytes([u8; 4])

Working Example

Example Snippetrust
fn main() {    let encoded = [0x34, 0x12, 0, 0];    println!("value: {}", u32::from_le_bytes(encoded));}
Rust Reference