Skip to main content

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

Implementations on Foreign Types§

Source§

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

Source§

fn zero() -> X

Source§

fn map(a: Self) -> X

Source§

fn u_map<U>(_: &mut U, a: Self) -> 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: Default + Add<X, Output = X> + Copy, &'a X: Add<&'a X, Output = X>,

Source§

fn zero() -> X

Source§

fn map(a: Self) -> X

Source§

fn u_map<U>(_: &mut U, a: Self) -> 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<X, Output = X>,