Apply suggestions from code review

Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
Irevoire 2021-09-22 16:59:23 +02:00 committed by Tamo
parent 47ee93b0bd
commit 218f0a6661
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
3 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
//! This module provide the `AscDesc` type and define a all the errors related to this type //! This module provides the `AscDesc` type and defines all the errors related to this type.
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
@ -43,7 +43,7 @@ impl From<AscDescError> for CriterionError {
AscDescError::ReservedKeyword { name } if name.starts_with("_geoRadius") => { AscDescError::ReservedKeyword { name } if name.starts_with("_geoRadius") => {
CriterionError::ReservedNameForFilter { name: "_geoRadius".to_string() } CriterionError::ReservedNameForFilter { name: "_geoRadius".to_string() }
} }
AscDescError::ReservedKeyword { name } => (CriterionError::ReservedName { name }), AscDescError::ReservedKeyword { name } => CriterionError::ReservedName { name },
} }
} }
} }
@ -129,7 +129,7 @@ impl FromStr for AscDesc {
type Err = AscDescError; type Err = AscDescError;
/// Since we don't know if this was deserialized for a criterion or a sort we just return a /// Since we don't know if this was deserialized for a criterion or a sort we just return a
/// string and let the caller create his own error /// string and let the caller create his own error.
fn from_str(text: &str) -> Result<AscDesc, Self::Err> { fn from_str(text: &str) -> Result<AscDesc, Self::Err> {
match text.rsplit_once(':') { match text.rsplit_once(':') {
Some((left, "asc")) => Ok(AscDesc::Asc(left.parse()?)), Some((left, "asc")) => Ok(AscDesc::Asc(left.parse()?)),

View File

@ -24,17 +24,17 @@ impl fmt::Display for CriterionError {
Self::ReservedNameForSort { name } => { Self::ReservedNameForSort { name } => {
write!( write!(
f, f,
"{0} is a reserved keyword and thus can't be used as a ranking rule. \ "{} is a reserved keyword and thus can't be used as a ranking rule. \
{0} can only be used for sorting at search time", {} can only be used for sorting at search time",
name name, name
) )
} }
Self::ReservedNameForFilter { name } => { Self::ReservedNameForFilter { name } => {
write!( write!(
f, f,
"{0} is a reserved keyword and thus can't be used as a ranking rule. \ "{} is a reserved keyword and thus can't be used as a ranking rule. \
{0} can only be used for filtering at search time", {} can only be used for filtering at search time",
name name, name
) )
} }
} }

View File

@ -210,7 +210,7 @@ impl fmt::Display for UserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match self {
Self::AttributeLimitReached => f.write_str("maximum number of attributes reached"), Self::AttributeLimitReached => f.write_str("maximum number of attributes reached"),
Self::CriterionError(error) => f.write_str(&error.to_string()), Self::CriterionError(error) => write!(f, "{}", error),
Self::DocumentLimitReached => f.write_str("maximum number of documents reached"), Self::DocumentLimitReached => f.write_str("maximum number of documents reached"),
Self::InvalidFacetsDistribution { invalid_facets_name } => { Self::InvalidFacetsDistribution { invalid_facets_name } => {
let name_list = let name_list =