[][src]Function tao_of_rust::ch04::general_concepts::memory_align

pub fn memory_align()

内存对齐:

Base usage: 结构体内存对齐

struct A {
    a: u8,
    b: u32,
    c: u16,
}
fn main() {
    println!("{:?}", std::mem::size_of::<A>());   // 8
}             // ------+Run

Base usage: Union内存对齐

union U {
    f1: u32,
    f2: f32,
    f3: f64
}
fn main() {
    println!("{:?}", std::mem::size_of::<U>());  // 8
}Run