getrandom is often used to generate seed for user-space PRNG. #279 adds unsafe raw API which allows to remove redundant initialization of buffers. So I wonder if it could be worth to introduce the following safe wrappers:
pubfngetrandom_array<constN:usize>() -> Result<[u8;N],Error>{letmut buf = mem::MaybeUninit::<[u8;N]>::uninit();unsafe{getrandom_raw(buf.as_mut_ptr().cast(),N).map(|()| buf.assume_init())}}pubfngetrandom_u32() -> Result<u32,Error>{getrandom_array().map(u32::from_ne_bytes)}pubfngetrandom_u64() -> Result<u64,Error>{getrandom_array().map(u64::from_ne_bytes)}// and maybe other wrappers for u16, u128, i32, i64, etc.Of course, getrandom_array implies MSRV bump to 1.51, which could be done in sync with rand v0.9.
getrandomis often used to generate seed for user-space PRNG. #279 adds unsafe raw API which allows to remove redundant initialization of buffers. So I wonder if it could be worth to introduce the following safe wrappers:Of course,
getrandom_arrayimplies MSRV bump to 1.51, which could be done in sync withrand v0.9.