Skip to content

Commit

Permalink
add docs to FzfDistance
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 19, 2023
1 parent f79efcb commit 11a64ed
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/algos/fzf/distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use core::cmp::{Ord, PartialOrd};

pub(super) type Score = i64;

/// TODO: docs
/// An opaque distance type returned by [`FzfV1`](super::FzfV1) and
/// [`FzfV2`](super::FzfV2)'s [`Metric`](crate::Metric) implementations.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct FzfDistance(Score);

Expand All @@ -16,8 +17,7 @@ impl PartialOrd for FzfDistance {
impl Ord for FzfDistance {
#[inline]
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
// Putting other first makes the type act like a distance and not like
// a score.
// This makes the type act like a distance and not like a score.
other.0.cmp(&self.0)
}
}
Expand All @@ -30,13 +30,17 @@ impl Default for FzfDistance {
}

impl FzfDistance {
/// TODO: docs
/// Creates a new [`FzfDistance`] from a score.
#[inline(always)]
pub(super) fn from_score(score: Score) -> Self {
Self(score)
}

/// TODO: docs
/// Returns a score representation of the distance.
///
/// This is not part of the public API and should not be relied upon.
///
/// It's only used internally for testing and debugging purposes.
#[cfg(any(feature = "into-score", feature = "tests"))]
#[inline(always)]
pub fn into_score(self) -> Score {
Expand Down

0 comments on commit 11a64ed

Please sign in to comment.