pub trait Additive {
    // Required methods
    fn add(a: &Self, b: &Self) -> Self;
    fn sub(a: &Self, b: &Self) -> Self;
    fn negate(x: &Self) -> Self;

    // Provided method
    fn double(x: &Self) -> Self
       where Self: Sized { ... }
}

Required Methods§

source

fn add(a: &Self, b: &Self) -> Self

source

fn sub(a: &Self, b: &Self) -> Self

source

fn negate(x: &Self) -> Self

Provided Methods§

source

fn double(x: &Self) -> Self
where Self: Sized,

Takes x, returns x + x

This can be more efficient than calling Self::add(x, x)

Object Safety§

This trait is not object safe.

Implementors§