2665: 📎 makes clippy happy r=Kerollmops a=irevoire



Co-authored-by: Irevoire <tamo@meilisearch.com>
This commit is contained in:
bors[bot] 2022-08-16 12:01:56 +00:00 committed by GitHub
commit 8198bb9da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 16 deletions

View File

@ -119,7 +119,7 @@ async fn get_tasks(
// Then we complete the task filter with other potential status and types filters. // Then we complete the task filter with other potential status and types filters.
let filters = if type_.is_some() || status.is_some() { let filters = if type_.is_some() || status.is_some() {
let mut filters = indexes_filters.unwrap_or_default(); let mut filters = indexes_filters.unwrap_or_default();
filters.filter_fn(move |task| { filters.filter_fn(Box::new(move |task| {
let matches_type = match &type_ { let matches_type = match &type_ {
Some(types) => types Some(types) => types
.iter() .iter()
@ -135,7 +135,7 @@ async fn get_tasks(
}; };
matches_type && matches_status matches_type && matches_status
}); }));
Some(filters) Some(filters)
} else { } else {
indexes_filters indexes_filters

View File

@ -143,7 +143,7 @@ impl MetadataVersion {
} }
} }
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum DumpStatus { pub enum DumpStatus {
Done, Done,

View File

@ -31,7 +31,7 @@ pub const DEFAULT_HIGHLIGHT_POST_TAG: fn() -> String = || "</em>".to_string();
/// will be able to return in one search call. /// will be able to return in one search call.
pub const DEFAULT_PAGINATION_MAX_TOTAL_HITS: usize = 1000; pub const DEFAULT_PAGINATION_MAX_TOTAL_HITS: usize = 1000;
#[derive(Deserialize, Debug, Clone, PartialEq)] #[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)] #[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct SearchQuery { pub struct SearchQuery {
pub q: Option<String>, pub q: Option<String>,

View File

@ -31,10 +31,10 @@ where
.serialize(s) .serialize(s)
} }
#[derive(Clone, Default, Debug, Serialize, PartialEq)] #[derive(Clone, Default, Debug, Serialize, PartialEq, Eq)]
pub struct Checked; pub struct Checked;
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Unchecked; pub struct Unchecked;
#[cfg_attr(test, derive(proptest_derive::Arbitrary))] #[cfg_attr(test, derive(proptest_derive::Arbitrary))]

View File

@ -416,7 +416,7 @@ impl Scheduler {
} }
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq, Eq)]
pub enum Processing { pub enum Processing {
DocumentAdditions(Vec<TaskId>), DocumentAdditions(Vec<TaskId>),
IndexUpdate(TaskId), IndexUpdate(TaskId),

View File

@ -128,7 +128,7 @@ impl Task {
} }
} }
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))] #[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub enum DocumentDeletion { pub enum DocumentDeletion {
Clear, Clear,

View File

@ -22,11 +22,13 @@ pub use store::test::MockStore as Store;
#[cfg(not(test))] #[cfg(not(test))]
pub use store::Store; pub use store::Store;
type FilterFn = Box<dyn Fn(&Task) -> bool + Sync + Send + 'static>;
/// Defines constraints to be applied when querying for Tasks from the store. /// Defines constraints to be applied when querying for Tasks from the store.
#[derive(Default)] #[derive(Default)]
pub struct TaskFilter { pub struct TaskFilter {
indexes: Option<HashSet<String>>, indexes: Option<HashSet<String>>,
filter_fn: Option<Box<dyn Fn(&Task) -> bool + Sync + Send + 'static>>, filter_fn: Option<FilterFn>,
} }
impl TaskFilter { impl TaskFilter {
@ -51,8 +53,8 @@ impl TaskFilter {
.insert(index); .insert(index);
} }
pub fn filter_fn(&mut self, f: impl Fn(&Task) -> bool + Sync + Send + 'static) { pub fn filter_fn(&mut self, f: FilterFn) {
self.filter_fn.replace(Box::new(f)); self.filter_fn.replace(f);
} }
} }

View File

@ -372,9 +372,6 @@ pub mod test {
let tasks = store.list_tasks(&txn, None, Some(filter), None).unwrap(); let tasks = store.list_tasks(&txn, None, Some(filter), None).unwrap();
assert_eq!(tasks.len(), 1); assert_eq!(tasks.len(), 1);
assert_eq!( assert_eq!(tasks.first().as_ref().unwrap().index_uid().unwrap(), "test");
&*tasks.first().as_ref().unwrap().index_uid().unwrap(),
"test"
);
} }
} }

View File

@ -5,7 +5,7 @@ use std::str::FromStr;
/// An index uid is composed of only ascii alphanumeric characters, - and _, between 1 and 400 /// An index uid is composed of only ascii alphanumeric characters, - and _, between 1 and 400
/// bytes long /// bytes long
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "test-traits", derive(proptest_derive::Arbitrary))] #[cfg_attr(feature = "test-traits", derive(proptest_derive::Arbitrary))]
pub struct IndexUid( pub struct IndexUid(
#[cfg_attr(feature = "test-traits", proptest(regex("[a-zA-Z0-9_-]{1,400}")))] String, #[cfg_attr(feature = "test-traits", proptest(regex("[a-zA-Z0-9_-]{1,400}")))] String,