pub trait Distance<D> {
type Output: Num;
// Required method
fn distance(&self, other: &Self, desc: D) -> Self::Output;
}Expand description
The abstract notion of the distance between two values.
This can be used to calculate the distance between two arbitrary values without storing their difference as an intermediate result.
Required Associated Types§
Required Methods§
Sourcefn distance(&self, other: &Self, desc: D) -> Self::Output
fn distance(&self, other: &Self, desc: D) -> Self::Output
Calculates the distance between self and other.
§Panics
An implementation of distance may panic if the operands
do not fit together, e.g. have different sizes etc.
§Example
use num_complex::Complex;
use norman::Distance;
use norman::desc::Abs;
assert_eq!(Complex::new(2.0, 5.0).distance(&Complex::new(-1.0, 1.0), Abs::new()), 5.0);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.