-
-
Notifications
You must be signed in to change notification settings - Fork 480
Description
Background
What is your motivation? Right now, the Rng::fill function can only write to buffers that are already initialized. That's because passing uninitialized memory as a &[T] is undefined behavior. With an AsByteSliceMut implementation for [MaybeUninit<T>], rand could be used to write vast amounts of random numbers into memory without needing to zero out the memory before.
What type of application is this? Fast generation of vast amounts of numbers
Feature request
The rand::AsByteSliceMut trait should be implemented for all [MaybeUninit<T>] where T are the numeric integer types. In other words, similar to how you can fill a &mut [u32]/&mut [i32]/&mut [usize]/... or a &mut [Wrapping<u32>]/&mut [Wrapping<i32>]/&mut [Wrapping<usize>]/..., rand should support filling a &mut [MaybeUninit<u32>]/&mut [MaybeUninit<i32>]/&mut [MaybeUninit<usize>]/...