@@ -90,19 +90,31 @@ pub trait BlockRngCore {
90
90
///
91
91
/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods
92
92
/// reading values from the results buffer, as well as
93
- /// calling `BlockRngCore::generate` directly on the output array when
94
- /// `fill_bytes` / `try_fill_bytes` is called on a large array. These methods
93
+ /// calling [ `BlockRngCore::generate`] directly on the output array when
94
+ /// [ `fill_bytes`] / [ `try_fill_bytes`] is called on a large array. These methods
95
95
/// also handle the bookkeeping of when to generate a new batch of values.
96
- /// No generated values are ever thown away and all values are consumed
97
- /// in-order (this may be important for reproducibility).
96
+ ///
97
+ /// No whole generated `u32` values are thown away and all values are consumed
98
+ /// in-order. [`next_u32`] simply takes the next available `u32` value.
99
+ /// [`next_u64`] is implemented by combining two `u32` values, least
100
+ /// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole
101
+ /// number of `u32` values, converting each `u32` to a byte slice in
102
+ /// little-endian order. If the requested byte length is not a multiple of 4,
103
+ /// some bytes will be discarded.
98
104
///
99
105
/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is
100
106
/// no direct support for other buffer types.
101
107
///
102
108
/// For easy initialization `BlockRng` also implements [`SeedableRng`].
103
109
///
104
110
/// [`BlockRngCore`]: BlockRngCore.t.html
111
+ /// [`BlockRngCore::generate`]: trait.BlockRngCore.html#tymethod.generate
112
+ /// [`BlockRng64`]: struct.BlockRng64.html
105
113
/// [`RngCore`]: ../RngCore.t.html
114
+ /// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
115
+ /// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
116
+ /// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
117
+ /// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
106
118
/// [`SeedableRng`]: ../SeedableRng.t.html
107
119
#[ derive( Clone ) ]
108
120
#[ cfg_attr( feature="serde1" , derive( Serialize , Deserialize ) ) ]
@@ -289,15 +301,23 @@ impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R> {
289
301
/// This is similar to [`BlockRng`], but specialized for algorithms that operate
290
302
/// on `u64` values.
291
303
///
292
- /// Like [`BlockRng`], this wrapper does not throw away whole results and does
293
- /// use all generated values in-order. The behaviour of `next_u32` is however
294
- /// a bit special: half of a `u64` is consumed, leaving the other half in the
295
- /// buffer. If the next function called is `next_u32` then the other half is
296
- /// then consumed, however both `next_u64` and `fill_bytes` discard any
297
- /// half-consumed `u64`s when called.
304
+ /// No whole generated `u64` values are thrown away and all values are consumed
305
+ /// in-order. [`next_u64`] simply takes the next available `u64` value.
306
+ /// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving
307
+ /// the other half in the buffer. If the next function called is [`next_u32`]
308
+ /// then the other half is then consumed, however both [`next_u64`] and
309
+ /// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called.
310
+ ///
311
+ /// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64`
312
+ /// values. If the requested length is not a multiple of 8, some bytes will be
313
+ /// discarded.
298
314
///
299
315
/// [`BlockRngCore`]: BlockRngCore.t.html
300
316
/// [`RngCore`]: ../RngCore.t.html
317
+ /// [`next_u32`]: ../trait.RngCore.html#tymethod.next_u32
318
+ /// [`next_u64`]: ../trait.RngCore.html#tymethod.next_u64
319
+ /// [`fill_bytes`]: ../trait.RngCore.html#tymethod.fill_bytes
320
+ /// [`try_fill_bytes`]: ../trait.RngCore.html#tymethod.try_fill_bytes
301
321
/// [`BlockRng`]: struct.BlockRng.html
302
322
#[ derive( Clone ) ]
303
323
#[ cfg_attr( feature="serde1" , derive( Serialize , Deserialize ) ) ]
0 commit comments