[][src]Macro bump_into::space

macro_rules! space {
    ($capacity:expr) => { ... };
    ($like_ty:ty; $capacity:expr) => { ... };
}

Creates an uninitialized array of MaybeUninit on the stack, suitable for taking a slice of to pass into BumpInto::from_slice.

Examples

use bump_into::space;
use core::mem;

// an array of MaybeUninit<u8> is created by default:
let mut space = space!(64);
assert_eq!(mem::size_of_val(&space), 64);
assert_eq!(mem::align_of_val(&space), 1);
// you can also specify a type if you need your space to
// have a particular alignment:
let mut space = space!(u32; 16);
assert_eq!(mem::size_of_val(&space), 64);
assert_eq!(mem::align_of_val(&space), 4);