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 { ... }
}
Expand description
Type for which addition is defined
Required Methods§
Provided Methods§
Sourcefn double(x: &Self) -> Selfwhere
Self: Sized,
fn double(x: &Self) -> Selfwhere
Self: Sized,
Takes x
, returns x + x
This can be more efficient than calling Self::add(x, x)
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.