Skip to main content

LegacyRandom

Struct LegacyRandom 

pub struct LegacyRandom { /* private fields */ }

Implementations§

§

impl LegacyRandom

pub fn new(seed: i64) -> LegacyRandom

pub const fn from_state(state: u64) -> LegacyRandom

Construct from an already-masked 48-bit state.

pub fn state(&self) -> u64

The 48-bit generator state (differential tests compare it).

Trait Implementations§

§

impl Clone for LegacyRandom

§

fn clone(&self) -> LegacyRandom

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for LegacyRandom

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<(u64, Option<f64>)> for LegacyRandom

A generator from its state (masked to 48 bits) and cached gaussian.

§

fn from(_: (u64, Option<f64>)) -> LegacyRandom

Converts to this type from the input type.
§

impl RandomSource for LegacyRandom

§

type Positional = LegacyPositionalRandom

§

fn fork_positional(&mut self) -> <LegacyRandom as RandomSource>::Positional

§

fn set_seed(&mut self, seed: i64)

§

fn next_int(&mut self) -> i32

§

fn next_int_bound(&mut self, bound: i32) -> Result<i32, InvalidBound>

§

fn next_long(&mut self) -> i64

§

fn next_boolean(&mut self) -> bool

§

fn next_float(&mut self) -> f32

§

fn next_double(&mut self) -> f64

§

fn next_gaussian(&mut self) -> f64

MarsagliaPolarGaussian over this source; the cached second value is part of the source state (reset by set_seed where vanilla resets it).
§

fn fork(&mut self) -> LegacyRandom

§

fn consume_count(&mut self, count: i32)

§

fn next_int_between_inclusive( &mut self, min: i32, max: i32, ) -> Result<i32, InvalidBound>

§

fn next_int_between( &mut self, origin: i32, bound: i32, ) -> Result<i32, InvalidBound>

§

fn triangle(&mut self, mean: f64, deviation: f64) -> f64

§

fn triangle_float(&mut self, mean: f32, deviation: f32) -> f32

§

impl Wire for LegacyRandom

The whole generator, through its own constructor, which masks the state to 48 bits.

§

const MIN: usize = 9

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn take(input: &mut Reader<'_>) -> Result<LegacyRandom, WireError>

Decodes one value, leaving any following bytes for the caller.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

impl WorldgenSource for LegacyRandom

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Put for T
where T: Wire,

§

fn put_to(&self, out: &mut Writer)

Writes it.
§

impl<T> Record for T
where T: Wire,

§

fn encode(&self, out: &mut Writer)

Writes the argument into a hook call.
§

fn apply(&mut self, bytes: &[u8]) -> Result<(), WireError>

Applies one complete reply, refusing malformed or trailing bytes atomically.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.