From 83e20027fdbe054f7212236033fe8a55097dfe7b Mon Sep 17 00:00:00 2001 From: Irevoire Date: Fri, 12 Aug 2022 14:18:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8E=20makes=20clippy=20happy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meilisearch-http/src/routes/tasks.rs | 4 ++-- meilisearch-lib/src/dump/mod.rs | 2 +- meilisearch-lib/src/index/search.rs | 2 +- meilisearch-lib/src/index/updates.rs | 4 ++-- meilisearch-lib/src/tasks/scheduler.rs | 2 +- meilisearch-lib/src/tasks/task.rs | 2 +- meilisearch-lib/src/tasks/task_store/mod.rs | 8 +++++--- meilisearch-lib/src/tasks/task_store/store.rs | 2 +- meilisearch-types/src/index_uid.rs | 2 +- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index 016aadfb8..50902485b 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -119,7 +119,7 @@ async fn get_tasks( // Then we complete the task filter with other potential status and types filters. let filters = if type_.is_some() || status.is_some() { 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_ { Some(types) => types .iter() @@ -135,7 +135,7 @@ async fn get_tasks( }; matches_type && matches_status - }); + })); Some(filters) } else { indexes_filters diff --git a/meilisearch-lib/src/dump/mod.rs b/meilisearch-lib/src/dump/mod.rs index ea7b9f3dc..10a3216f2 100644 --- a/meilisearch-lib/src/dump/mod.rs +++ b/meilisearch-lib/src/dump/mod.rs @@ -143,7 +143,7 @@ impl MetadataVersion { } } -#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] +#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] #[serde(rename_all = "snake_case")] pub enum DumpStatus { Done, diff --git a/meilisearch-lib/src/index/search.rs b/meilisearch-lib/src/index/search.rs index 58bcf7ef4..97f68b524 100644 --- a/meilisearch-lib/src/index/search.rs +++ b/meilisearch-lib/src/index/search.rs @@ -31,7 +31,7 @@ pub const DEFAULT_HIGHLIGHT_POST_TAG: fn() -> String = || "".to_string(); /// will be able to return in one search call. 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)] pub struct SearchQuery { pub q: Option, diff --git a/meilisearch-lib/src/index/updates.rs b/meilisearch-lib/src/index/updates.rs index 07695af05..a31df3d34 100644 --- a/meilisearch-lib/src/index/updates.rs +++ b/meilisearch-lib/src/index/updates.rs @@ -31,10 +31,10 @@ where .serialize(s) } -#[derive(Clone, Default, Debug, Serialize, PartialEq)] +#[derive(Clone, Default, Debug, Serialize, PartialEq, Eq)] pub struct Checked; -#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct Unchecked; #[cfg_attr(test, derive(proptest_derive::Arbitrary))] diff --git a/meilisearch-lib/src/tasks/scheduler.rs b/meilisearch-lib/src/tasks/scheduler.rs index 9c181b86b..9975fa3b7 100644 --- a/meilisearch-lib/src/tasks/scheduler.rs +++ b/meilisearch-lib/src/tasks/scheduler.rs @@ -416,7 +416,7 @@ impl Scheduler { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Processing { DocumentAdditions(Vec), IndexUpdate(TaskId), diff --git a/meilisearch-lib/src/tasks/task.rs b/meilisearch-lib/src/tasks/task.rs index 42f75834f..7f9b72964 100644 --- a/meilisearch-lib/src/tasks/task.rs +++ b/meilisearch-lib/src/tasks/task.rs @@ -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))] pub enum DocumentDeletion { Clear, diff --git a/meilisearch-lib/src/tasks/task_store/mod.rs b/meilisearch-lib/src/tasks/task_store/mod.rs index 96777d628..621d66dd3 100644 --- a/meilisearch-lib/src/tasks/task_store/mod.rs +++ b/meilisearch-lib/src/tasks/task_store/mod.rs @@ -22,11 +22,13 @@ pub use store::test::MockStore as Store; #[cfg(not(test))] pub use store::Store; +type FilterFn = Box bool + Sync + Send + 'static>; + /// Defines constraints to be applied when querying for Tasks from the store. #[derive(Default)] pub struct TaskFilter { indexes: Option>, - filter_fn: Option bool + Sync + Send + 'static>>, + filter_fn: Option, } impl TaskFilter { @@ -51,8 +53,8 @@ impl TaskFilter { .insert(index); } - pub fn filter_fn(&mut self, f: impl Fn(&Task) -> bool + Sync + Send + 'static) { - self.filter_fn.replace(Box::new(f)); + pub fn filter_fn(&mut self, f: FilterFn) { + self.filter_fn.replace(f); } } diff --git a/meilisearch-lib/src/tasks/task_store/store.rs b/meilisearch-lib/src/tasks/task_store/store.rs index 9dfe61c55..c1cbfae47 100644 --- a/meilisearch-lib/src/tasks/task_store/store.rs +++ b/meilisearch-lib/src/tasks/task_store/store.rs @@ -373,7 +373,7 @@ pub mod test { assert_eq!(tasks.len(), 1); assert_eq!( - &*tasks.first().as_ref().unwrap().index_uid().unwrap(), + tasks.first().as_ref().unwrap().index_uid().unwrap(), "test" ); } diff --git a/meilisearch-types/src/index_uid.rs b/meilisearch-types/src/index_uid.rs index de453572b..a8cb726af 100644 --- a/meilisearch-types/src/index_uid.rs +++ b/meilisearch-types/src/index_uid.rs @@ -5,7 +5,7 @@ use std::str::FromStr; /// An index uid is composed of only ascii alphanumeric characters, - and _, between 1 and 400 /// bytes long -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "test-traits", derive(proptest_derive::Arbitrary))] pub struct IndexUid( #[cfg_attr(feature = "test-traits", proptest(regex("[a-zA-Z0-9_-]{1,400}")))] String,