pub fn getrandom_uninit(
    dest: &mut [MaybeUninit<u8>]
) -> Result<&mut [u8], Error>
Expand description

Version of the getrandom function which fills dest with random bytes returns a mutable reference to those bytes.

On successful completion this function is guaranteed to return a slice which points to the same memory as dest and has the same length. In other words, it’s safe to assume that dest is initialized after this function has returned Ok.

No part of dest will ever be de-initialized at any point, regardless of what is returned.

§Examples

#![feature(maybe_uninit_uninit_array)]
let mut buf = core::mem::MaybeUninit::uninit_array::<1024>();
let buf: &mut [u8] = getrandom::getrandom_uninit(&mut buf)?;