From 11a64ed47cb86c042795a211cf1d1696ebce8123 Mon Sep 17 00:00:00 2001 From: Riccardo Mazzarini Date: Sun, 19 Nov 2023 18:02:18 +0100 Subject: [PATCH] add docs to `FzfDistance` --- src/algos/fzf/distance.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/algos/fzf/distance.rs b/src/algos/fzf/distance.rs index dbd0dcb..a8839f7 100644 --- a/src/algos/fzf/distance.rs +++ b/src/algos/fzf/distance.rs @@ -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); @@ -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) } } @@ -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 {