File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,11 @@ thread_local!(
87
87
}
88
88
) ;
89
89
90
- /// Retrieve the lazily-initialized thread-local random number
91
- /// generator, seeded by the system. Intended to be used in method
92
- /// chaining style, e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g.
93
- /// `let mut rng = thread_rng();`.
90
+ /// Retrieve the lazily-initialized thread-local random number generator,
91
+ /// seeded by the system. Intended to be used in method chaining style,
92
+ /// e.g. `thread_rng().gen::<i32>()`, or cached locally, e.g.
93
+ /// `let mut rng = thread_rng();`. Invoked by the `Default` trait, making
94
+ /// `ThreadRng::default()` equivelent.
94
95
///
95
96
/// For more information see [`ThreadRng`].
96
97
///
@@ -99,6 +100,12 @@ pub fn thread_rng() -> ThreadRng {
99
100
ThreadRng { rng : THREAD_RNG_KEY . with ( |t| t. get ( ) ) }
100
101
}
101
102
103
+ impl Default for ThreadRng {
104
+ fn default ( ) -> ThreadRng {
105
+ :: prelude:: thread_rng ( )
106
+ }
107
+ }
108
+
102
109
impl RngCore for ThreadRng {
103
110
#[ inline( always) ]
104
111
fn next_u32 ( & mut self ) -> u32 {
You can’t perform that action at this time.
0 commit comments