From 5d5bcf7011bc87e48f5eea802051b6c6842aec46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 25 Feb 2019 18:39:58 +0100 Subject: [PATCH] feat: Remove the FilterFunc alias type --- meilidb-core/src/lib.rs | 2 +- meilidb-core/src/query_builder.rs | 6 ++---- meilidb/src/database/view.rs | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/meilidb-core/src/lib.rs b/meilidb-core/src/lib.rs index 7266aa87d..8b8606ddf 100644 --- a/meilidb-core/src/lib.rs +++ b/meilidb-core/src/lib.rs @@ -15,7 +15,7 @@ use slice_group_by::GroupBy; use rayon::slice::ParallelSliceMut; pub use self::index::{Index, IndexBuilder}; -pub use self::query_builder::{FilterFunc, QueryBuilder, DistinctQueryBuilder}; +pub use self::query_builder::{QueryBuilder, DistinctQueryBuilder}; /// Represent an internally generated document unique identifier. /// diff --git a/meilidb-core/src/query_builder.rs b/meilidb-core/src/query_builder.rs index 6d76cfb48..d5ec79a50 100644 --- a/meilidb-core/src/query_builder.rs +++ b/meilidb-core/src/query_builder.rs @@ -35,16 +35,14 @@ fn generate_automatons(query: &str) -> Vec { automatons } -pub type FilterFunc = fn(DocumentId) -> bool; - -pub struct QueryBuilder<'i, 'c, FI> { +pub struct QueryBuilder<'i, 'c, FI = fn(DocumentId) -> bool> { index: &'i Index, criteria: Criteria<'c>, searchable_attrs: Option>, filter: Option, } -impl<'i, 'c> QueryBuilder<'i, 'c, FilterFunc> { +impl<'i, 'c> QueryBuilder<'i, 'c, fn(DocumentId) -> bool> { pub fn new(index: &'i Index) -> Self { QueryBuilder::with_criteria(index, Criteria::default()) } diff --git a/meilidb/src/database/view.rs b/meilidb/src/database/view.rs index 8eb21a4c8..fcbb3fea1 100644 --- a/meilidb/src/database/view.rs +++ b/meilidb/src/database/view.rs @@ -6,8 +6,7 @@ use std::{fmt, marker}; use rocksdb::rocksdb_options::{ReadOptions, EnvOptions, ColumnFamilyOptions}; use rocksdb::rocksdb::{DB, DBVector, Snapshot, SeekKey, SstFileWriter}; use serde::de::DeserializeOwned; -use meilidb_core::{Index, QueryBuilder, FilterFunc}; -use meilidb_core::DocumentId; +use meilidb_core::{Index, QueryBuilder, DocumentId}; use crate::database::{retrieve_data_schema, retrieve_data_index, retrieve_data_ranked_map, retrieve_config}; use crate::database::serde::deserializer::Deserializer; @@ -84,7 +83,7 @@ where D: Deref Ok(()) } - pub fn query_builder(&self) -> QueryBuilder { + pub fn query_builder(&self) -> QueryBuilder { QueryBuilder::new(self.index()) }