diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-05-19 02:31:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-19 02:31:32 +0200 |
| commit | 7885dfc62385b722e04067b2d5c26aeea429fb02 (patch) | |
| tree | 0e2763a862c5adba15a38f940376f81ac71e92fd /src/liballoc | |
| parent | 963184bbb670c1ffa97fc28a98cd5e8473118859 (diff) | |
| parent | c0b6d3c975915e740548f0ec7bcf5963e7a3b218 (diff) | |
| download | rust-7885dfc62385b722e04067b2d5c26aeea429fb02.tar.gz rust-7885dfc62385b722e04067b2d5c26aeea429fb02.zip | |
Rollup merge of #60370 - Richard-W:const-layout-construction, r=sfackler
Mark core::alloc::Layout::from_size_align_unchecked const
Makes it possible (pending stabilization of #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.
Diffstat (limited to 'src/liballoc')
0 files changed, 0 insertions, 0 deletions
