Skip to main content

Superposition

Trait Superposition 

Source
pub trait Superposition<T> {
    // Required methods
    fn from_states(states: Vec<T>, amplitudes: Vec<Complex64>) -> Result<Self>
       where Self: Sized;
    fn collapse(&mut self) -> T;
    fn probability(&self, state: &T) -> f64;
    fn transform<F>(&mut self, f: F) -> Result<()>
       where F: Fn(&mut T);
}
Expand description

Superposition trait for objects that can exist in multiple states

Required Methods§

Source

fn from_states(states: Vec<T>, amplitudes: Vec<Complex64>) -> Result<Self>
where Self: Sized,

Create superposition from multiple states

Source

fn collapse(&mut self) -> T

Collapse superposition to single state

Source

fn probability(&self, state: &T) -> f64

Get probability of specific state

Source

fn transform<F>(&mut self, f: F) -> Result<()>
where F: Fn(&mut T),

Apply transformation to all states in superposition

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§