Struct weird_data::Wdg

source ·
pub struct Wdg(/* private fields */);
Expand description

A weird data generator

Implementations§

source§

impl Wdg

source

pub fn new() -> Self

Create a new Wdg by forking the global Wdg.

If you want to control the initial seed, use [with_seed] instead.

source§

impl Wdg

source

pub fn with_seed(seed: u64) -> Self

source

pub fn fork(&mut self) -> Self

source

pub fn seed(&mut self, seed: u64)

source

pub fn get_seed(&mut self) -> u64

source

pub fn nan_f32(&mut self) -> f32

Generates a random f32 NAN value.

There are multiple bit patterns that are equivalent to a NAN. This generator covers all possible NAN values as specified in IEEE-754, even ones that Rust would normally not generate.

source

pub fn nan_f64(&mut self) -> f64

Generates a random f64 NAN value.

There are multiple bit patterns that are equivalent to a NAN. This generator covers all possible NAN values as specified in IEEE-754, even ones that Rust would normally not generate.

source

pub fn subnormal_f32(&mut self) -> f32

Generates a random f32 denormal value.

This generator covers all possible denormal values as specified in IEEE-754.

source

pub fn subnormal_f64(&mut self) -> f64

Generates a random f64 denormal value.

This generator covers all possible denormal values as specified in IEEE-754.

source

pub fn normal_f32(&mut self) -> f32

Generate a random f32 normal value

source

pub fn normal_f64(&mut self) -> f64

Generate a random f64 normal value

source

pub fn special_f32(&mut self) -> f32

Generate a random f32 “special” value

A special value is what I call specific float values that are unique and are pretty much impossible to generate by chance, and have some unusual properties.

source

pub fn special_f64(&mut self) -> f64

Generate a random f64 “special” value

A special value is what I call specific float values that are unique and are pretty much impossible to generate by chance, and have some unusual properties.

source

pub fn f32(&mut self) -> f32

Generate a random f32, such that special or problematic values are much more common than normal.

The distribution is not statistically useful, but it ensures that all edge-case values get a fair chance of being generated. This is better than using a regular random number generator, because in the vast majority of cases, a random number generator will generate perfectly regular and well-behaved values, and certain values, like INFINITY and NAN may be impossible to generate.

The distribution is as follows:

  • 25% normal values
  • 25% subnormal values
  • 25% NAN values, including all possible payloads, quiet and signaling NAN.
  • 25% “special” values, i.e. unique values with special properties such as INFINITY and -0.0
source

pub fn f64(&mut self) -> f64

Generate a random f64, such that special or problematic values are much more common than normal.

The distribution is not statistically useful, but it ensures that all edge-case values get a fair chance of being generated. This is better than using a regular random number generator, because in the vast majority of cases, a random number generator will generate perfectly regular and well-behaved values, and certain values, like INFINITY and NAN may be impossible to generate.

The distribution is as follows:

  • 25% normal values
  • 25% subnormal values
  • 25% NAN values, including all possible payloads, quiet and signaling NAN.
  • 25% “special” values, i.e. unique values with special properties such as INFINITY and -0.0

Trait Implementations§

source§

impl Clone for Wdg

source§

fn clone(&self) -> Wdg

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Default for Wdg

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Wdg

§

impl Send for Wdg

§

impl Sync for Wdg

§

impl Unpin for Wdg

§

impl UnwindSafe for Wdg

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> 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.

source§

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

§

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>,

§

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>,

§

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.