From 7559e38d43ad1c0cdf1b6961ec8d882e50de331c Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 10 Jun 2023 07:04:03 -0700 Subject: [PATCH 1/3] Clarify documentation for fork() --- src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 415aae9..ce24096 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -282,21 +282,23 @@ impl Rng { /// Clones the generator by deterministically deriving a new generator based on the initial /// seed. + /// + /// This function can be used to create a new generator that is a "spinoff" of the old + /// generator. The new generator will not produce the same sequence of values as the + /// old generator. /// /// # Example /// /// ``` /// // Seed two generators equally, and clone both of them. - /// let mut base1 = fastrand::Rng::new(); - /// base1.seed(0x4d595df4d0f33173); + /// let mut base1 = fastrand::Rng::with_seed(0x4d595df4d0f33173); /// base1.bool(); // Use the generator once. /// - /// let mut base2 = fastrand::Rng::new(); - /// base2.seed(0x4d595df4d0f33173); + /// let mut base2 = fastrand::Rng::with_seed(0x4d595df4d0f33173); /// base2.bool(); // Use the generator once. /// - /// let mut rng1 = base1.clone(); - /// let mut rng2 = base2.clone(); + /// let mut rng1 = base1.fork(); + /// let mut rng2 = base2.fork(); /// /// assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical"); /// ``` From a8f6d4a351e92b58cc340195b1c4c5a90477cf46 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 10 Jun 2023 08:20:37 -0700 Subject: [PATCH 2/3] fmt --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ce24096..f8f3980 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -282,7 +282,7 @@ impl Rng { /// Clones the generator by deterministically deriving a new generator based on the initial /// seed. - /// + /// /// This function can be used to create a new generator that is a "spinoff" of the old /// generator. The new generator will not produce the same sequence of values as the /// old generator. From 36496d0b7d44ab1fec4b59b754c7217a81b47c5e Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 11 Jun 2023 07:09:30 -0700 Subject: [PATCH 3/3] Remove assert_eq from example --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f8f3980..f5acbde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -300,7 +300,8 @@ impl Rng { /// let mut rng1 = base1.fork(); /// let mut rng2 = base2.fork(); /// - /// assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical"); + /// println!("rng1 returns {}", rng1.u32(..)); + /// println!("rng2 returns {}", rng2.u32(..)); /// ``` #[inline] #[must_use = "this creates a new instance of `Rng`"]