pub trait InitZeroed<'a>: Sealed {
type Output: ?Sized;
// Required method
fn init_zeroed(self) -> BumpBox<'a, Self::Output> ⓘ;
}Expand description
Extension trait for BumpBox that adds the init_zeroed method.
Required Associated Types§
Required Methods§
Sourcefn init_zeroed(self) -> BumpBox<'a, Self::Output> ⓘ
fn init_zeroed(self) -> BumpBox<'a, Self::Output> ⓘ
Initializes self by filling it with zero.
§Examples
use bump_scope::{Bump, bytemuck::InitZeroed};
let bump: Bump = Bump::new();
// single value
let uninit = bump.alloc_uninit::<i32>();
let init = uninit.init_zeroed();
assert_eq!(*init, 0);
// slice
let uninit = bump.alloc_uninit_slice::<i32>(10);
let init = uninit.init_zeroed();
assert_eq!(*init, [0; 10]);