Struct schroedinger_box::SchroedingerBox [] [src]

pub struct SchroedingerBox<Cat> { /* fields omitted */ }

A box that contains many values, but collapses into one when opened (read from) for the first time.

Example

let cat_is_alive = SchroedingerBox::new(vec![true, false]);
// Here the cat is both dead and alive, but when we observe it...
let state = *cat_is_alive;
// ...it collapses into one of the possible states with equal probability.
assert_eq!(state, *cat_is_alive);

Methods

impl<Cat> SchroedingerBox<Cat>
[src]

Creates a new SchroedingerBox from a set of states.

When the box is first opened, the contents’ superposition will collapse into one of the given states with equal probability.

Panic

Panics if states.len() == 0.

Creates a new SchroedingerBox from a set of states, each with a probability.

When the box is first opened, the contents’ superposition will collapse into one of the given states with each state’s probability determined by the probabilities given.

The probablity for a state is represented by a ratio of an integer to the total sum of the probabilities; e.g., a set of states and probabilities [(1, true), (5, false)] would be false five sixths of the time and true one sixth of the time.

Panic

Panics if states.len() == 0.

Moves the value inside a SchroedingerBox out, consuming the box and collapsing any superposition into a definite state if needed.

Trait Implementations

impl<Cat> Deref for SchroedingerBox<Cat>
[src]

The resulting type after dereferencing

Obtains a reference to the value inside a SchroedingerBox, collapsing any superposition into a definite state if needed.

impl<Cat> DerefMut for SchroedingerBox<Cat>
[src]

Obtains a mutable reference to the value inside a SchroedingerBox, collapsing any superposition into a definite state if needed.

impl<Cat> Debug for SchroedingerBox<Cat> where
    Cat: Debug
[src]

Formats the value using the given formatter.

impl<Cat> Display for SchroedingerBox<Cat> where
    Cat: Display
[src]

Formats the value using the given formatter. Read more

impl<Cat> PartialEq for SchroedingerBox<Cat> where
    Cat: PartialEq
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<Cat> Eq for SchroedingerBox<Cat> where
    Cat: Eq
[src]

impl<Cat> PartialOrd for SchroedingerBox<Cat> where
    Cat: PartialOrd
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<Cat> Ord for SchroedingerBox<Cat> where
    Cat: Ord
[src]

This method returns an Ordering between self and other. Read more

impl<Cat> Default for SchroedingerBox<Cat> where
    Cat: Default
[src]

Returns the "default value" for a type. Read more

impl<Cat> Clone for SchroedingerBox<Cat> where
    Cat: Clone
[src]

Clones a SchroedingerBox.

This collapses any superposition into a single state.

Performs copy-assignment from source. Read more

impl<Cat> Hash for SchroedingerBox<Cat> where
    Cat: Hash
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more