From 9c25035440c31a32f52a794412e154448a192cc3 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 31 May 2026 13:54:23 -0700 Subject: [PATCH 1/2] Mention how to fill a buffer with random bytes --- library/std/src/random.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/random.rs b/library/std/src/random.rs index a18dcf98ec7fc..5daedf42a3591 100644 --- a/library/std/src/random.rs +++ b/library/std/src/random.rs @@ -16,6 +16,8 @@ use crate::sys::random as sys; /// security is not a concern, consider using an alternative random number /// generator (potentially seeded from this one). /// +/// If you need to fill a buffer with random bytes, use `DefaultRandomSource.fill_bytes(&mut buf)`. +/// /// # Underlying sources /// /// Platform | Source From f65c5656ff068ec5dcbfa26bce42e91b20c4f604 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 31 May 2026 13:54:35 -0700 Subject: [PATCH 2/2] Add doc aliases for `DefaultRandomSource`, for people looking for 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. --- library/std/src/random.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/random.rs b/library/std/src/random.rs index 5daedf42a3591..8274060e5cedf 100644 --- a/library/std/src/random.rs +++ b/library/std/src/random.rs @@ -56,6 +56,7 @@ use crate::sys::random as sys; /// /// [`getrandom`]: https://www.man7.org/linux/man-pages/man2/getrandom.2.html /// [`/dev/urandom`]: https://www.man7.org/linux/man-pages/man4/random.4.html +#[doc(alias = "getrandom", alias = "getentropy", alias = "arc4random")] #[derive(Default, Debug, Clone, Copy)] #[unstable(feature = "random", issue = "130703")] pub struct DefaultRandomSource;