Skip to main content

SimilarityFn

Trait SimilarityFn 

Source
pub trait SimilarityFn: Send + Sync {
    // Required methods
    fn similarity(&self, a: &FieldValue, b: &FieldValue) -> f32;
    fn field_kind(&self) -> FieldKind;

    // Provided method
    fn similarity_str(&self, a: &str, b: &str) -> f32 { ... }
}
Expand description

Returns a similarity in [0.0, 1.0]. 0.0 = completely different, 1.0 = identical.

Required Methods§

Provided Methods§

Source

fn similarity_str(&self, a: &str, b: &str) -> f32

Zero-alloc hot path for pool-native comparison.

Called by compare_pool_field to avoid wrapping &str in FieldValue::Text on every comparison. Override in concrete types to eliminate the allocation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§