Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#60370 - Richard-W:const-layout-construction…
…, r=sfackler Mark core::alloc::Layout::from_size_align_unchecked const Makes it possible (pending stabilization of rust-lang#57563 (`const_fn`)) to rewrite code like ```rust const BUFFER_SIZE: usize = 0x2000; const BUFFER_ALIGN: usize = 0x1000; fn foo() { let layout = std::alloc::Layout::from_size_align(BUFFER_SIZE, BUFFER_ALIGN) .unwrap(); let buffer = std::alloc::alloc(layout); } ``` to ```rust const BUFFER_LAYOUT: std::alloc::Layout = unsafe { std::alloc::Layout::from_size_align_unchecked(0x2000, 0x1000) }; fn foo() { let buffer = std::alloc::alloc(BUFFER_LAYOUT); } ``` which (although `unsafe` is used) looks somewhat cleaner and is easier to read.
- Loading branch information