@@ -862,20 +862,7 @@ pub fn weak_rng() -> XorShiftRng {
862
862
}
863
863
}
864
864
865
- /// Controls how the thread-local RNG is reseeded.
866
- #[ derive( Debug ) ]
867
- struct ThreadRngReseeder ;
868
-
869
- impl reseeding:: Reseeder < StdRng > for ThreadRngReseeder {
870
- fn reseed ( & mut self , rng : & mut StdRng ) {
871
- * rng = match StdRng :: new ( ) {
872
- Ok ( r) => r,
873
- Err ( e) => panic ! ( "could not reseed thread_rng: {}" , e)
874
- }
875
- }
876
- }
877
- const THREAD_RNG_RESEED_THRESHOLD : u64 = 32_768 ;
878
- type ThreadRngInner = reseeding:: ReseedingRng < StdRng , ThreadRngReseeder > ;
865
+ type ThreadRngInner = os:: OsRng ;
879
866
880
867
/// The thread-local RNG.
881
868
#[ derive( Clone , Debug ) ]
@@ -889,21 +876,13 @@ pub struct ThreadRng {
889
876
///
890
877
/// The RNG provided will reseed itself from the operating system
891
878
/// after generating a certain amount of randomness.
892
- ///
893
- /// The internal RNG used is platform and architecture dependent, even
894
- /// if the operating system random number generator is rigged to give
895
- /// the same sequence always. If absolute consistency is required,
896
- /// explicitly select an RNG, e.g. `IsaacRng` or `Isaac64Rng`.
897
879
pub fn thread_rng ( ) -> ThreadRng {
898
880
// used to make space in TLS for a random number generator
899
881
thread_local ! ( static THREAD_RNG_KEY : Rc <RefCell <ThreadRngInner >> = {
900
- let r = match StdRng :: new( ) {
882
+ let rng = match os :: OsRng :: new( ) {
901
883
Ok ( r) => r,
902
884
Err ( e) => panic!( "could not initialize thread_rng: {}" , e)
903
885
} ;
904
- let rng = reseeding:: ReseedingRng :: new( r,
905
- THREAD_RNG_RESEED_THRESHOLD ,
906
- ThreadRngReseeder ) ;
907
886
Rc :: new( RefCell :: new( rng) )
908
887
} ) ;
909
888
0 commit comments