Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork14.5k
Open
Description
Feature gate:#![feature(random)]
This is a tracking issue for secure random data generation support instd.
Central to this feature is theRandomSource trait insidecore::random, which generates random bytes.std also exposes the platform's secure random number generator via theDefaultRandomSource type. There is aDistribution<T> trait for distributions that cansample random values of a specific type, and arandom function for convenience to allow things likerandom(1..=6).
Public API
// core::randompubtraitRandomSource{fnfill_bytes(&mutself,bytes:&mut[u8]);}pubtraitDistribution<T>{fnsample(&self,source:&mut(implRandomSource + ?Sized)) ->T;}implDistribution<bool>forRangeFull{ ...}implDistribution</* all integer types */>for/* all range types */{ ...}// std::random (additionally)pubstructDefaultRandomSource;implRandomSourceforDefaultRandomSource{ ...}pubfnrandom<T>(dist:&(implDistribution<T> + ?Sized)) ->T;
Steps / History
- ACP:Simple secure random number generation libs-team#393
- Implementation
- std: implement the
randomfeature (alternative version) #129201 - API rework for
Distribution<T>and newrandom
- std: implement the
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Naming: the ACP used
gen_bytesandDefaultRng, the implementation PR usesfill_bytesandDefaultRandomSource(see argumentsprogen_bytesandprofill_bytes) - Concerns listed atSimple secure random number generation libs-team#393 (comment) should be addressed