neek-core 0.1.0

Core fuzzy matching and scoring engine
Documentation
//! Fuzzy matching and scoring engine.
//!
//! # Quick start
//!
//! ```rust
//! use neek_core::{has_match, score, score_positions};
//!
//! let needle = b"src";
//! let haystack = b"src/main.rs";
//!
//! assert!(has_match(needle, haystack));
//!
//! let s = score(needle, haystack);
//! println!("score: {s}");
//!
//! let mut positions = vec![0usize; needle.len()];
//! let s2 = score_positions(needle, haystack, &mut positions);
//! assert_eq!(s, s2);
//! println!("matched at positions: {:?}", positions);
//! ```

#![no_std]
extern crate alloc;

mod algorithm;
mod bonus;

pub mod config;

#[cfg(test)] mod tests;

pub use algorithm::{has_match, score, score_positions};

/// Numeric type used for all scores.
pub type Score = f64;

/// Returned when a candidate is an exact (case-insensitive) match for the
/// needle, or when the needle is empty and all candidates match trivially.
pub const SCORE_MAX: Score = f64::INFINITY;

/// Returned when a candidate cannot be scored (too long, no match, or the
/// needle is empty at the `score` call site).
pub const SCORE_MIN: Score = f64::NEG_INFINITY;

/// Maximum haystack/needle length that the DP scorer handles. Candidates
/// longer than this are given `SCORE_MIN` by `score` / `score_positions`.
pub const MATCH_MAX_LEN: usize = 1024;