Layout — 메모리 레이아웃 설명

Layout — 메모리 레이아웃 설명

Layout는 메모리 할당의 레이아웃을 설명하는 타입이에요. 크기(size)와 정렬(alignment)을 나타내요.

출처: Rust 공식 문서

본문

pub struct Layout { /* private fields */ }

주요 메서드

pub const fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutError>
pub const fn size(&self) -> usize
pub const fn align(&self) -> usize (non_exhaustive)
pub const fn array<T>(n: usize) -> Result<Self, LayoutError>
pub fn pad_to_align(&self) -> Layout
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError>

할당자는 크기와 정렬, 그리고 할당 크기가 정렬의 배수인지(compatible)를 보장해야 해요.

더 알아보기 (Learn more)