Skip to content

Commit e5b9884

Browse files
authored
Rollup merge of rust-lang#157221 - joshtriplett:random-source-doc-alias, r=jhpratt
Help people looking for random bytes find `DefaultRandomSource.fill_bytes` Mention, in the `DefaultRandomSource` docs, how to fill a buffer with random bytes. Add doc aliases for `DefaultRandomSource`, for people looking for various sources of randomness. `getrandom` is both a crate for this and the name of the underlying syscall on various OSes. `getentropy` and `arc4random` are common library calls on various OSes.
2 parents 9e6dd14 + f65c565 commit e5b9884

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

library/std/src/random.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use crate::sys::random as sys;
1616
/// security is not a concern, consider using an alternative random number
1717
/// generator (potentially seeded from this one).
1818
///
19+
/// If you need to fill a buffer with random bytes, use `DefaultRandomSource.fill_bytes(&mut buf)`.
20+
///
1921
/// # Underlying sources
2022
///
2123
/// Platform | Source
@@ -54,6 +56,7 @@ use crate::sys::random as sys;
5456
///
5557
/// [`getrandom`]: https://www.man7.org/linux/man-pages/man2/getrandom.2.html
5658
/// [`/dev/urandom`]: https://www.man7.org/linux/man-pages/man4/random.4.html
59+
#[doc(alias = "getrandom", alias = "getentropy", alias = "arc4random")]
5760
#[derive(Default, Debug, Clone, Copy)]
5861
#[unstable(feature = "random", issue = "130703")]
5962
pub struct DefaultRandomSource;

0 commit comments

Comments
 (0)