norm/metrics/fzf/
distance.rs1use core::cmp::{Ord, PartialOrd};
2
3pub(super) type Score = i64;
4
5#[derive(Debug, Clone, Copy, Eq, PartialEq)]
10pub struct FzfDistance(Score);
11
12impl PartialOrd for FzfDistance {
13 #[inline]
14 fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
15 Some(self.cmp(other))
16 }
17}
18
19impl Ord for FzfDistance {
20 #[inline]
21 fn cmp(&self, other: &Self) -> core::cmp::Ordering {
22 other.0.cmp(&self.0)
24 }
25}
26
27impl Default for FzfDistance {
28 #[inline]
29 fn default() -> Self {
30 Self::from_score(0)
31 }
32}
33
34impl FzfDistance {
35 #[inline(always)]
37 pub(super) fn from_score(score: Score) -> Self {
38 Self(score)
39 }
40
41 #[cfg(any(feature = "__into-score", feature = "__tests"))]
47 #[inline(always)]
48 pub fn into_score(self) -> Score {
49 self.0
50 }
51}