File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 11use hybrid_array:: { Array , ArraySize } ;
22use rand_core:: { CryptoRng , TryCryptoRng } ;
33
4+ #[ cfg( feature = "getrandom" ) ]
5+ use getrandom:: { SysRng , rand_core:: UnwrapErr } ;
6+
47/// Secure random generation.
58pub trait Generate : Sized {
69 /// Generate random key using the provided [`TryCryptoRng`].
@@ -20,7 +23,7 @@ pub trait Generate: Sized {
2023 /// failure.
2124 #[ cfg( feature = "getrandom" ) ]
2225 fn try_generate ( ) -> Result < Self , getrandom:: Error > {
23- Self :: try_generate_from_rng ( & mut getrandom :: SysRng )
26+ Self :: try_generate_from_rng ( & mut SysRng )
2427 }
2528
2629 /// Randomly generate a value of this type using the system's ambient cryptographically secure
@@ -33,7 +36,7 @@ pub trait Generate: Sized {
3336 /// This shouldn't happen on most modern operating systems.
3437 #[ cfg( feature = "getrandom" ) ]
3538 fn generate ( ) -> Self {
36- Self :: try_generate ( ) . expect ( "RNG failure" )
39+ Self :: generate_from_rng ( & mut UnwrapErr ( SysRng ) )
3740 }
3841}
3942
You can’t perform that action at this time.
0 commit comments