devela/num/rand/
mod.rs

1// devela::num::rand
2//
3//! Random number generation.
4//!
5//! This module defines several types:
6//! - RNG algorithms specialized for 8-bit devices:
7//!   [`Xabc`], [`Xyza8a`], [`Xyza8b`].
8//! - Classic *XorShift* algorithms and variations with a smaller state.
9//!
10//! The RNGs implement `Copy` for convenience and versatility.
11//! Be careful to not duplicate the state by accident.
12//!
13//! The `Default` implementation uses a fixed seed for convenience.
14//! Use a custom seed for unique random sequences.
15//!
16//! [`RngCore`]: https://docs.rs/rand_core/latest/rand_core/trait.RngCore.html
17//!
18//! # Features
19//! All <abbr title="Pseudo-Random Number Generator">PRNG</abbr>s require the
20//! `rand` feature, except for [`XorShift128p`], which is always compiled.
21//
22
23mod xorshift;
24
25#[cfg(feature = "rand")]
26crate::items! {
27    #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "rand")))]
28    mod lgc;
29    #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "rand")))]
30    mod xoroshiro;
31    #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "rand")))]
32    mod xyza8;
33    #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "rand")))]
34    mod xabc;
35}
36
37crate::items! { // structural access: _mods, _internals, _all
38    #[allow(unused)]
39    pub use {_mods::*, _internals::*};
40
41    mod _mods {
42        pub use super::xorshift::*;
43        #[cfg(feature = "rand")]
44        pub use super::{lgc::*, xabc::*, xoroshiro::*, xyza8::*};
45    }
46    pub(super) mod _internals { #![allow(unused)]
47        #[cfg(feature = "rand")]
48        pub(crate) use super::xorshift::xorshift_basis;
49    }
50    pub(super) mod _all {
51        #[doc(inline)]
52        pub use super::_mods::*;
53    }
54}