Skip to main content

crypto_bigint/limb/
rand.rs

1//! Random number generator support
2
3use super::Limb;
4use rand_core::{CryptoRng, RngCore};
5
6impl Limb {
7    /// Generate a random limb
8    #[cfg(target_pointer_width = "32")]
9    #[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
10    pub fn random(mut rng: impl CryptoRng + RngCore) -> Self {
11        Self(rng.next_u32())
12    }
13
14    /// Generate a random limb
15    #[cfg(target_pointer_width = "64")]
16    #[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
17    pub fn random(mut rng: impl CryptoRng + RngCore) -> Self {
18        Self(rng.next_u64())
19    }
20}