pub struct Distance(/* private fields */);Expand description
Pairwise distance in [0.0, 1.0]. Smaller = more similar.
Layer 1 (cluster, cluster_with_candidates) requires every distance
value to land in this range; the type system enforces it. Built-in metric
constructors on Config always return valid Distance values. For
user-supplied distance closures, construct values via Distance::new
(fail-fast on out-of-range) or Distance::clamped (saturate, NaN →
Distance::MAX).
Implementations§
Source§impl Distance
impl Distance
Sourcepub fn new(value: f32) -> Option<Self>
pub fn new(value: f32) -> Option<Self>
Construct from a raw f32. Returns None if the value is NaN,
infinite, or outside [0.0, 1.0].
Sourcepub fn clamped(value: f32) -> Self
pub fn clamped(value: f32) -> Self
Construct, clamping out-of-range values to the nearest endpoint.
NaN becomes Distance::MAX — treating an unknowable distance as
“definitely not a match” so it never merges two clusters.
Trait Implementations§
impl Copy for Distance
Source§impl PartialOrd for Distance
impl PartialOrd for Distance
impl StructuralPartialEq for Distance
Auto Trait Implementations§
impl Freeze for Distance
impl RefUnwindSafe for Distance
impl Send for Distance
impl Sync for Distance
impl Unpin for Distance
impl UnsafeUnpin for Distance
impl UnwindSafe for Distance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more