Merge pull request #101 from meilisearch/criterion-display

implement display for criterion
This commit is contained in:
Clément Renault 2021-03-08 13:29:05 +01:00 committed by GitHub
commit 08a0ff7091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt;
use anyhow::{Context, bail};
use regex::Regex;
@ -63,3 +64,20 @@ pub fn default_criteria() -> Vec<Criterion> {
Criterion::Exactness,
]
}
impl fmt::Display for Criterion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use Criterion::*;
match self {
Typo => f.write_str("typo"),
Words => f.write_str("words"),
Proximity => f.write_str("proximity"),
Attribute => f.write_str("attribute"),
WordsPosition => f.write_str("wordsPosition"),
Exactness => f.write_str("exactness"),
Asc(attr) => write!(f, "asc({})", attr),
Desc(attr) => write!(f, "desc({})", attr),
}
}
}