pub fn fuzzy_match<T>(&self, values: &[&T]) -> Option<usize>
    where
        for<'a> &'a T: Searchable,
    {
        let options = SearchOptions::new().levenshtein(true).threshold(0.5);
        let mut engine = SimSearch::new_with(options);

        values.iter().enumerate().for_each(|(i, s)| {
            engine.insert(i, s.search_key());
        });

        match self.args.get(0) {
            Some(arg) => {
                let results = engine.search(arg);

                if results.is_empty() {
                    return None;
                }

                // return index of the most relevant match
                Some(results[0])
            }
            None => None,
        }
    }
/// Performs a fuzzy search and comparison of the command input (first
/// argument) against the supplied values. The values are any entity that
/// implements the `Searchable` trait.
///
/// This will return the index of the most relevant match within the
/// original collection.
///
/// This uses the SimSearch levenshtein implementation, which has a
/// limitation of ASCII-only strings. UTF-8 string compatability can be
/// enabled by removing this option. The benefit is that the search is
/// SIMD-powered and MUCH faster.
///
/// @TODO: Make this configurable via the game config file.
/// @TODO: Return the reference to T instead of the index in the collection.
Performs a fuzzy search and comparison of the command input (first
argument) against the supplied values. The values are any entity that
implements the `Searchable` trait.

This will return the index of the most relevant match within the
original collection.

This uses the SimSearch levenshtein implementation, which has a
limitation of ASCII-only strings. UTF-8 string compatability can be
enabled by removing this option. The benefit is that the search is
SIMD-powered and MUCH faster.
Performs a fuzzy search and comparison of the command input ( first argument ) against the supplied values . The values are any entity that implements the ` Searchable ` trait . This will return the index of the most relevant match within the original collection . This uses the SimSearch levenshtein implementation which has a limitation of ASCII - only strings . UTF - 8 string compatability can be enabled by removing this option . The benefit is that the search is SIMD - powered and MUCH faster .
pub fn fuzzy_match<T>(&self, values: &[&T]) -> Option<usize>
    where
        for<'a> &'a T: Searchable,
    {
        let options = SearchOptions::new().levenshtein(true).threshold(0.5);
        let mut engine = SimSearch::new_with(options);
        values.iter().enumerate().for_each(|(i, s)| {
            engine.insert(i, s.search_key());
        });
        match self.args.get(0) {
            Some(arg) => {
                let results = engine.search(arg);
                if results.is_empty() {
                    return None;
                }
                // return index of the most relevant match
                Some(results[0])
            }
            None => None,
        }
    }
pub fn fuzzy_match < T > ( & self , values : & [ & T ] ) -> Option < usize > where for < ' a > & ' a T : Searchable , { let options = SearchOptions :: new ( ) . levenshtein ( true ) . threshold ( 0.5 ) ; let mut engine = SimSearch :: new_with ( options ) ; values . iter ( ) . enumerate ( ) . for_each ( | ( i , s ) | { engine . insert ( i , s . search_key ( ) ) ; } ) ; match self . args . get ( 0 ) { Some ( arg ) => { let results = engine . search ( arg ) ; if results . is_empty ( ) { return None ; } // return index of the most relevant match Some ( results [ 0 ] ) } None => None , } }
Performs a fuzzy search and comparison of the command input (first
argument) against the supplied values.
Performs a fuzzy search and comparison of the command input ( first argument ) against the supplied values .
&self
values
&[&T]
&self
values
&[&T]
TODO:
Make this configurable via the game config file.
Make this configurable via the game config file .
TODO:
Return the reference to T instead of the index in the collection.
Return the reference to T instead of the index in the collection .