Metric

Trait Metric 

Source
pub trait Metric<T> {
    // Required method
    fn distance(a: &[T], b: &[T]) -> f32;
}
Expand description

A trait for calculating distance between two vectors.

Required Methods§

Source

fn distance(a: &[T], b: &[T]) -> f32

Calculates the distance between two vectors.

§Arguments
  • a - The first vector.
  • b - The second vector.
§Returns

The distance as a floating-point value.

§Panics

Implementations MUST panic if:

  • The vectors have different lengths.
  • The inputs contain NaN (for float types).

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.

Implementors§