Sum

Trait Sum 

Source
pub trait Sum<Output> {
    // Required methods
    fn zero() -> Output;
    fn map(a: Self) -> Output;
    fn u_map<U>(_: &mut U, a: Self) -> Output;
    fn reduce(a: Output, b: Output) -> Output;
    fn u_reduce<U>(_: &mut U, a: Output, b: Output) -> Output;
}
Expand description

Number that can be summed over.

Required Methodsยง

Source

fn zero() -> Output

Zero.

Source

fn map(a: Self) -> Output

Maps the number to owned value.

Source

fn u_map<U>(_: &mut U, a: Self) -> Output

Maps the number to owned value.

Source

fn reduce(a: Output, b: Output) -> Output

Returns sum of a and b.

Source

fn u_reduce<U>(_: &mut U, a: Output, b: Output) -> Output

Returns sum of a and b.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Typesยง

Sourceยง

impl<'a, X> Sum<X> for &'a X
where X: Add<Output = X> + Copy + Default, &'a X: Add<Output = X>,

Sourceยง

fn zero() -> X

Sourceยง

fn map(a: &'a X) -> X

Sourceยง

fn u_map<U>(_: &mut U, a: &'a X) -> X

Sourceยง

fn reduce(a: X, b: X) -> X

Sourceยง

fn u_reduce<U>(_: &mut U, a: X, b: X) -> X

Sourceยง

impl<'a, X> Sum<X> for &'a mut X
where X: Add<Output = X> + Copy + Default, &'a X: Add<Output = X>,

Sourceยง

fn zero() -> X

Sourceยง

fn map(a: &'a mut X) -> X

Sourceยง

fn u_map<U>(_: &mut U, a: &'a mut X) -> X

Sourceยง

fn reduce(a: X, b: X) -> X

Sourceยง

fn u_reduce<U>(_: &mut U, a: X, b: X) -> X

Implementorsยง

Sourceยง

impl<X> Sum<X> for X
where X: Default + Add<Output = X>,