mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-11 22:14:32 +01:00
Apply suggestions from code review
Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
parent
47ee93b0bd
commit
218f0a6661
@ -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()?)),
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user