Crates.io | alloca |
lib.rs | alloca |
version | 0.4.0 |
source | src |
created_at | 2021-01-27 18:32:37.841408 |
updated_at | 2023-08-03 12:08:27.714601 |
description | Mostly safe wrapper for alloca |
homepage | |
repository | https://github.com/playXE/alloca-rs |
max_upload_size | |
id | 347417 |
size | 9,334 |
Mostly safe no_std wrapper for alloca
in Rust.
This crate uses Rust lifetime system to ensure that stack allocated memory will not be used after function return, but it does not make any guarantee about memory that is turned into raw pointer and stored somewhere else.
fn main() {
// allocate 128 bytes on the stack
alloca::with_alloca(128, |memory| {
// memory: &mut [MaybeUninit<u8>]
assert_eq!(memory.len(), 128);
});
}