surrealdb-sql 1.1.0

Full type definitions for the SurrealQL query language
Documentation
use fuzzy_matcher::skim::SkimMatcherV2;
use fuzzy_matcher::FuzzyMatcher;
use once_cell::sync::Lazy;

static MATCHER: Lazy<SkimMatcherV2> = Lazy::new(|| SkimMatcherV2::default().ignore_case());

pub trait Fuzzy {
	/// Retrieve the fuzzy similarity score of this &str compared to another &str
	fn fuzzy_match(&self, other: &str) -> bool;
	/// Check if this &str matches another &str using a fuzzy algorithm
	fn fuzzy_score(&self, other: &str) -> i64;
}

impl Fuzzy for str {
	/// Retrieve the fuzzy similarity score of this &str compared to another &str
	fn fuzzy_match(&self, other: &str) -> bool {
		MATCHER.fuzzy_match(self, other).is_some()
	}
	/// Check if this &str matches another &str using a fuzzy algorithm
	fn fuzzy_score(&self, other: &str) -> i64 {
		MATCHER.fuzzy_match(self, other).unwrap_or(0)
	}
}