mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-10-23 20:16:29 +00:00
feat: Introduce the Criterion::name
to allow better debugging
This commit is contained in:
@@ -9,4 +9,8 @@ impl Criterion for DocumentId {
|
||||
fn evaluate(&self, lhs: &RawDocument, rhs: &RawDocument) -> Ordering {
|
||||
lhs.id.cmp(&rhs.id)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"DocumentId"
|
||||
}
|
||||
}
|
||||
|
@@ -36,4 +36,8 @@ impl Criterion for Exact {
|
||||
|
||||
lhs.cmp(&rhs).reverse()
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"Exact"
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,9 @@ pub use self::{
|
||||
pub trait Criterion: Send + Sync {
|
||||
fn evaluate(&self, lhs: &RawDocument, rhs: &RawDocument) -> Ordering;
|
||||
|
||||
#[inline]
|
||||
fn name(&self) -> &'static str;
|
||||
|
||||
#[inline]
|
||||
fn eq(&self, lhs: &RawDocument, rhs: &RawDocument) -> bool {
|
||||
self.evaluate(lhs, rhs) == Ordering::Equal
|
||||
@@ -33,6 +36,10 @@ impl<'a, T: Criterion + ?Sized + Send + Sync> Criterion for &'a T {
|
||||
(**self).evaluate(lhs, rhs)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
(**self).name()
|
||||
}
|
||||
|
||||
fn eq(&self, lhs: &RawDocument, rhs: &RawDocument) -> bool {
|
||||
(**self).eq(lhs, rhs)
|
||||
}
|
||||
@@ -43,6 +50,10 @@ impl<T: Criterion + ?Sized> Criterion for Box<T> {
|
||||
(**self).evaluate(lhs, rhs)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
(**self).name()
|
||||
}
|
||||
|
||||
fn eq(&self, lhs: &RawDocument, rhs: &RawDocument) -> bool {
|
||||
(**self).eq(lhs, rhs)
|
||||
}
|
||||
|
@@ -24,4 +24,8 @@ impl Criterion for NumberOfWords {
|
||||
|
||||
lhs.cmp(&rhs).reverse()
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"NumberOfWords"
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,10 @@ impl Criterion for SumOfTypos {
|
||||
|
||||
lhs.cmp(&rhs).reverse()
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"SumOfTypos"
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@@ -35,4 +35,8 @@ impl Criterion for SumOfWordsAttribute {
|
||||
|
||||
lhs.cmp(&rhs)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"SumOfWordsAttribute"
|
||||
}
|
||||
}
|
||||
|
@@ -35,4 +35,8 @@ impl Criterion for SumOfWordsPosition {
|
||||
|
||||
lhs.cmp(&rhs)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"SumOfWordsPosition"
|
||||
}
|
||||
}
|
||||
|
@@ -98,6 +98,10 @@ impl Criterion for WordsProximity {
|
||||
|
||||
lhs.cmp(&rhs)
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"WordsProximity"
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user