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::str::FromStr;
@ -43,7 +43,7 @@ impl From<AscDescError> for CriterionError {
AscDescError::ReservedKeyword { name } if name.starts_with("_geoRadius") => {
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;
/// 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> {
match text.rsplit_once(':') {
Some((left, "asc")) => Ok(AscDesc::Asc(left.parse()?)),

View File

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

View File

@ -210,7 +210,7 @@ impl fmt::Display for UserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
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::InvalidFacetsDistribution { invalid_facets_name } => {
let name_list =