pub struct Mt19937 { /* private fields */ }Expand description
PHP’s Mersenne Twister (Random\Engine\Mt19937 in MT_RAND_MT19937
mode, the default engine).
Implementations§
Source§impl Mt19937
impl Mt19937
Sourcepub fn new(seed: i64) -> Self
pub fn new(seed: i64) -> Self
A generator seeded like mt_srand($seed): the seed is the low 32
bits of the integer, as PHP casts it.
Sourcepub fn from_entropy() -> Self
pub fn from_entropy() -> Self
A generator seeded from the operating system, as PHP seeds its default engine on first use.
Sourcepub fn range(&mut self, min: i64, max: i64) -> i64
pub fn range(&mut self, min: i64, max: i64) -> i64
mt_rand($min, $max): uniform in min..=max without modulo bias
(php_random_range). max below min wraps the way PHP’s unsigned
arithmetic does; mt_rand() itself refuses that before drawing.
Sourcepub fn array_rand(&mut self, len: usize) -> Result<usize, EngineError>
pub fn array_rand(&mut self, len: usize) -> Result<usize, EngineError>
array_rand($list) for a list (a packed array without holes) of len
elements: the index of one. An empty list is the ValueError PHP
throws, and draws nothing.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Mt19937
impl Freeze for Mt19937
impl Move for Mt19937
impl RefUnwindSafe for Mt19937
impl Send for Mt19937
impl Sync for Mt19937
impl Unpin for Mt19937
impl UnsafeUnpin for Mt19937
impl UnwindSafe for Mt19937
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more