Skip to content

Commit 4c94798

Browse files
committed
random: Add comment on RandomSource::fill_bytes about multiple calls
This allows efficient implementations for random sources that generate a word at a time.
1 parent e3fccdd commit 4c94798

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/random.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
#[unstable(feature = "random", issue = "130703")]
88
pub trait RandomSource {
99
/// Fills `bytes` with random bytes.
10+
///
11+
/// Note that calling `fill_bytes` multiple times is not equivalent to calling `fill_bytes` once
12+
/// with a larger buffer. A `RandomSource` is allowed to return different bytes for those two
13+
/// cases. For instance, this allows a `RandomSource` to generate a word at a time and throw
14+
/// part of it away if not needed.
1015
fn fill_bytes(&mut self, bytes: &mut [u8]);
1116
}
1217

0 commit comments

Comments
 (0)