Skip to content

Commit

Permalink
Initial eddie support completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
leontoeides committed Nov 18, 2023
1 parent 8de387a commit 87763c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ repository = "https://github.com/leontoeides/indicium"
maintenance = { status = "actively-developed" }

[features]
default = [ "simple", "strsim", "eddie", "ahash" ]
default = [ "simple", "strsim", "ahash" ]
simple = []
select2 = [ "simple", "serde" ]
ahash = [ "dep:ahash" ]
eddie = [ "dep:eddie" ]
gxhash = [ "dep:gxhash" ]
strsim = [ "dep:strsim" ]

[dependencies]
ahash = { version = "0.8", optional = true }
eddie = { version = "0.4", optional = true }
gxhash = { version = "2.2", optional = true }
kstring = "2.0"
serde = { version = "1.0", features = [ "derive" ], optional = true }
strsim = { version = "0.10", optional = true }
Expand Down
5 changes: 4 additions & 1 deletion src/simple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! The simple Indicium search implementation. Fewer bells-and-whistles but
//! easier to use than the other options.
//!
//! There will be more search implementations in future versions.
//! There might be more search implementations in future versions.

#[cfg(all(feature = "eddie", feature = "strsim"))]
compile_error!("feature `eddie` and `strsim` are mutually exclusive and cannot be enabled together");

// Directories:
mod autocomplete;
Expand Down
8 changes: 6 additions & 2 deletions src/simple/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,17 @@ fn simple() {
assert_eq!(autocomplete_options, vec!["1087".to_string()]);

// Test internal global fuzzy keyword search interface:
#[cfg(any(feature = "eddie", feature = "strsim"))]
#[cfg(feature = "eddie")]
let similar_keyword = search_index.eddie_global_keyword(&"Willy".to_lowercase());
#[cfg(feature = "strsim")]
let similar_keyword = search_index.strsim_global_keyword(&"Willy".to_lowercase());
#[cfg(any(feature = "eddie", feature = "strsim"))]
assert_eq!(similar_keyword, Some(&KString::from_ref("william")));

// Test internal global fuzzy autocompletion interface:
#[cfg(any(feature = "eddie", feature = "strsim"))]
#[cfg(feature = "eddie")]
let similar_autocompletions = search_index.eddie_global_autocomplete(&"Normy".to_lowercase());
#[cfg(feature = "strsim")]
let similar_autocompletions = search_index.strsim_global_autocomplete(&"Normy".to_lowercase());
#[cfg(any(feature = "eddie", feature = "strsim"))]
let similar_autocompletions_vec: Vec<&KString> = similar_autocompletions.into_iter().map(|(keyword, _keys)| keyword).collect();
Expand Down

0 comments on commit 87763c7

Please sign in to comment.