pub trait Distance:
Copy
+ Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn distance(a: &[f32], b: &[f32]) -> f32;
fn to_actual(d: f32) -> f32;
fn as_enum() -> DistanceFunction;
}Expand description
Trait for distance computation with compile-time dispatch
Required Methods§
Sourcefn distance(a: &[f32], b: &[f32]) -> f32
fn distance(a: &[f32], b: &[f32]) -> f32
Compute distance between two vectors (for comparisons, may skip sqrt for L2)
Sourcefn to_actual(d: f32) -> f32
fn to_actual(d: f32) -> f32
Convert comparison distance to actual distance (applies sqrt for L2)
Sourcefn as_enum() -> DistanceFunction
fn as_enum() -> DistanceFunction
Get the enum variant for runtime dispatch when needed
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.