From d44652209dce455cf45513330836dd8e88b585af Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Wed, 30 Nov 2022 14:52:20 +0100 Subject: [PATCH] impl Display for v2::settings::Criterion --- dump/src/reader/v2/settings.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dump/src/reader/v2/settings.rs b/dump/src/reader/v2/settings.rs index 62e5c05f9..1a7935b56 100644 --- a/dump/src/reader/v2/settings.rs +++ b/dump/src/reader/v2/settings.rs @@ -1,4 +1,5 @@ use std::collections::{BTreeMap, BTreeSet}; +use std::fmt::Display; use std::marker::PhantomData; use std::str::FromStr; @@ -174,3 +175,17 @@ impl FromStr for Criterion { } } } + +impl Display for Criterion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Criterion::Words => write!(f, "words"), + Criterion::Typo => write!(f, "typo"), + Criterion::Proximity => write!(f, "proximity"), + Criterion::Attribute => write!(f, "attribute"), + Criterion::Exactness => write!(f, "exactness"), + Criterion::Asc(field_name) => write!(f, "asc({})", field_name), + Criterion::Desc(field_name) => write!(f, "desc({})", field_name), + } + } +}