std-type
Rust Layout
A Layout describes storage size and required alignment. A descriptor can represent zero bytes, but a direct global allocator request must satisfy the allocator contract, including nonzero size for alloc. Creating a layout does not initialize anything. Expected stdout (not executed): size=9 alignment=1 Common mistake: Assuming that a valid Layout always permits calling alloc.
Formal Syntax & Structure
rust syntaxrust
Layout::new::<T>()Working Example
Example Snippetrust
#![deny(unsafe_op_in_unsafe_fn)]fn main() { use std::alloc::Layout; let layout = Layout::new::<[u8; 9]>(); println!("size={} alignment={}", layout.size(), layout.align());}