#![allow(stable_features)]
#![feature(avx512_target_feature)]
#![feature(portable_simd)]
#![feature(get_mut_unchecked)]
use std::cmp::Ordering;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
pub mod r#const;
pub mod incremental;
pub mod one_shot;
pub mod prefilter;
pub mod smith_waterman;
pub use incremental::IncrementalMatcher;
pub use one_shot::{match_indices, match_list, match_list_parallel};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Match {
pub score: u16,
pub index_in_haystack: u32,
pub exact: bool,
}
impl PartialOrd for Match {
fn partial_cmp(&self, other: &Match) -> Option<Ordering> {
Some(std::cmp::Ord::cmp(self, other))
}
}
impl Ord for Match {
fn cmp(&self, other: &Self) -> Ordering {
self.score
.cmp(&other.score)
.reverse()
.then_with(|| self.index_in_haystack.cmp(&other.index_in_haystack))
}
}
impl PartialEq for Match {
fn eq(&self, other: &Self) -> bool {
self.score == other.score && self.index_in_haystack == other.index_in_haystack
}
}
impl Eq for Match {}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MatchIndices {
pub score: u16,
pub indices: Vec<usize>,
pub exact: bool,
}
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Options {
pub prefilter: bool,
pub max_typos: Option<u16>,
pub sort: bool,
}
impl Default for Options {
fn default() -> Self {
Options {
prefilter: true,
max_typos: Some(0),
sort: true,
}
}
}