Trait outmove_common::types::gas_schedule::GasAlgebra[][src]

pub trait GasAlgebra<GasCarrier>: Sized where
    GasCarrier: Add<Output = GasCarrier> + Sub<Output = GasCarrier> + Div<Output = GasCarrier> + Mul<Output = GasCarrier> + Copy
{ fn new(carrier: GasCarrier) -> Self;
fn get(&self) -> GasCarrier; fn map<F: Fn(GasCarrier) -> GasCarrier>(self, f: F) -> Self { ... }
fn map2<F: Fn(GasCarrier, GasCarrier) -> GasCarrier>(
        self,
        other: impl GasAlgebra<GasCarrier>,
        f: F
    ) -> Self { ... }
fn app<T, F: Fn(GasCarrier, GasCarrier) -> T>(
        &self,
        other: &impl GasAlgebra<GasCarrier>,
        f: F
    ) -> T { ... }
fn unitary_cast<T: GasAlgebra<GasCarrier>>(self) -> T { ... }
fn add(self, right: impl GasAlgebra<GasCarrier>) -> Self { ... }
fn sub(self, right: impl GasAlgebra<GasCarrier>) -> Self { ... }
fn mul(self, right: impl GasAlgebra<GasCarrier>) -> Self { ... }
fn div(self, right: impl GasAlgebra<GasCarrier>) -> Self { ... } }

A trait encoding the operations permitted on the underlying carrier for the gas unit, and how other gas-related units can interact with other units -- operations can only be performed across units with the same underlying carrier (i.e. as long as the underlying data is the same).

Required methods

fn new(carrier: GasCarrier) -> Self[src]

Project a value into the gas algebra.

fn get(&self) -> GasCarrier[src]

Get the carrier.

Loading content...

Provided methods

fn map<F: Fn(GasCarrier) -> GasCarrier>(self, f: F) -> Self[src]

Map a function f of one argument over the underlying data.

fn map2<F: Fn(GasCarrier, GasCarrier) -> GasCarrier>(
    self,
    other: impl GasAlgebra<GasCarrier>,
    f: F
) -> Self
[src]

Map a function f of two arguments over the underlying carrier. Note that this function can take two different implementations of the trait -- one for self the other for the second argument. But, we enforce that they have the same underlying carrier.

fn app<T, F: Fn(GasCarrier, GasCarrier) -> T>(
    &self,
    other: &impl GasAlgebra<GasCarrier>,
    f: F
) -> T
[src]

Apply a function f of two arguments to the carrier. Since f is not an endomorphism, we return the resulting value, as opposed to the result wrapped up in ourselves.

fn unitary_cast<T: GasAlgebra<GasCarrier>>(self) -> T[src]

We allow casting between GasAlgebras as long as they have the same underlying carrier -- i.e. they use the same type to store the underlying value.

fn add(self, right: impl GasAlgebra<GasCarrier>) -> Self[src]

Add the two GasAlgebras together.

fn sub(self, right: impl GasAlgebra<GasCarrier>) -> Self[src]

Subtract one GasAlgebra from the other.

fn mul(self, right: impl GasAlgebra<GasCarrier>) -> Self[src]

Multiply two GasAlgebras together.

fn div(self, right: impl GasAlgebra<GasCarrier>) -> Self[src]

Divide one GasAlgebra by the other.

Loading content...

Implementors

Loading content...