@@ -67,7 +67,7 @@ impl ReseedingCore {
6767 #[ inline( never) ]
6868 fn try_to_reseed ( & mut self ) {
6969 if let Err ( e) = self . reseed ( ) {
70- panic ! ( "Reseeding RNG failed : {e}" ) ;
70+ panic ! ( "could not reseed ThreadRng : {e}" ) ;
7171 }
7272 }
7373}
@@ -103,7 +103,7 @@ impl ReseedingCore {
103103/// We leave it to the user to determine whether this generator meets their
104104/// security requirements. For an alternative, see [`SysRng`].
105105///
106- /// # Fork
106+ /// # Forks and interrupts
107107///
108108/// `ThreadRng` is not automatically reseeded on fork. It is recommended to
109109/// explicitly call [`ThreadRng::reseed`] immediately after a fork, for example:
@@ -121,7 +121,13 @@ impl ReseedingCore {
121121/// from an interrupt (e.g. a fork handler) unless it can be guaranteed that no
122122/// other method on the same `ThreadRng` is currently executing.
123123///
124+ /// # Panics
125+ ///
126+ /// Implementations of [`TryRng`] and [`Rng`] panic in case of [`SysRng`]
127+ /// failure during reseeding (highly unlikely).
128+ ///
124129/// [`StdRng`]: crate::rngs::StdRng
130+ /// [`Rng`]: rand_core::Rng
125131#[ derive( Clone ) ]
126132pub struct ThreadRng {
127133 // Rc is explicitly !Send and !Sync
@@ -188,6 +194,10 @@ thread_local!(
188194/// # Security
189195///
190196/// Refer to [`ThreadRng#Security`].
197+ ///
198+ /// # Panics
199+ ///
200+ /// This method panics in case of [`SysRng`] failure during initial seeding.
191201pub fn rng ( ) -> ThreadRng {
192202 let rng = THREAD_RNG_KEY . with ( |t| t. clone ( ) ) ;
193203 ThreadRng { rng }
0 commit comments