Skip to content

Commit 2833c78

Browse files
authored
Document Rng::fill, random differences
1 parent f7bbcca commit 2833c78

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/rng.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ pub trait Rng: RngCore {
7373
/// generated.
7474
///
7575
/// For arrays of integers, especially for those with small element types
76-
/// (< 64 bit), it will likely be faster to instead use [`Rng::fill`].
76+
/// (< 64 bit), it will likely be faster to instead use [`Rng::fill`],
77+
/// though note that generated values will differ.
7778
///
7879
/// ```
7980
/// use rand::{thread_rng, Rng};
@@ -223,6 +224,10 @@ pub trait Rng: RngCore {
223224

224225
/// Fill any type implementing [`Fill`] with random data
225226
///
227+
/// This method is implemented for types which may be safely reinterpreted
228+
/// as an (aligned) `[u8]` slice then filled with random data. It is often
229+
/// faster than using [`Rng::random`] but not value-equivalent.
230+
///
226231
/// The distribution is expected to be uniform with portable results, but
227232
/// this cannot be guaranteed for third-party implementations.
228233
///

0 commit comments

Comments
 (0)