[−][src]Struct artichoke_backend::extn::core::random::Random
Implementations
impl Random
[src]
pub fn new() -> Result<Self, Error>
[src]
pub fn with_seed(seed: Option<u64>) -> Result<Self, Error>
[src]
pub fn with_array_seed(seed: Option<[u32; 4]>) -> Result<Self, Error>
[src]
pub fn bytes(&mut self, size: Int) -> Result<Vec<u8>, Error>
[src]
pub fn rand(&mut self, constraint: Max) -> Result<Rand, Error>
[src]
#[must_use]pub fn seed(&self) -> Int
[src]
Methods from Deref<Target = SpinosoRandom>
#[must_use]pub fn next_int32(&mut self) -> u32
[src]
Generate next u32
output.
Generates a random number on (0..=0xffffffff)
-interval.
u32
is the native output of the generator. This function advances the
RNG step counter by one.
Examples
let mut random = Random::new()?; assert_ne!(random.next_int32(), random.next_int32());
#[must_use]pub fn next_real(&mut self) -> f64
[src]
Generate next f64
output.
Generates a random number on [0,1) with 53-bit resolution.
Examples
let mut random = Random::new()?; assert_ne!(random.next_real(), random.next_real());
pub fn fill_bytes(&mut self, dest: &mut [u8])
[src]
Fill a buffer with bytes generated from the RNG.
This method generates random u32
s (the native output unit of the RNG)
until dest
is filled.
This method may discard some output bits if dest.len()
is not a
multiple of 4.
Examples
let mut random = Random::new()?; let mut buf = [0; 32]; random.fill_bytes(&mut buf); assert_ne!([0; 32], buf); let mut buf = [0; 31]; random.fill_bytes(&mut buf); assert_ne!([0; 31], buf);
#[must_use]pub const fn seed(&self) -> [u32; 4]
[src]
Returns the seed value used to initialize the generator.
This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers.
Examples
let seed = [1_u32, 2, 3, 4]; let random = Random::with_array_seed(seed); assert_eq!(random.seed(), seed);
Trait Implementations
impl AsMut<Random> for Random
[src]
fn as_mut(&mut self) -> &mut SpinosoRandom
[src]
impl AsRef<Random> for Random
[src]
fn as_ref(&self) -> &SpinosoRandom
[src]
impl Clone for Random
[src]
impl Debug for Random
[src]
impl Default for Random
[src]
impl Deref for Random
[src]
type Target = SpinosoRandom
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for Random
[src]
impl Eq for Random
[src]
impl Hash for Random
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Random> for Random
[src]
impl StructuralEq for Random
[src]
impl StructuralPartialEq for Random
[src]
Auto Trait Implementations
impl RefUnwindSafe for Random
[src]
impl Send for Random
[src]
impl Sync for Random
[src]
impl Unpin for Random
[src]
impl UnwindSafe for Random
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,