use crate::multi_vector::{MatRef, MaxSimError, Standard};
pub trait MaxSimKernel<T: Copy>: Send + Sync + std::fmt::Debug {
fn nrows(&self) -> usize;
fn compute_max_sim(
&self,
doc: MatRef<'_, Standard<T>>,
scores: &mut [f32],
) -> Result<(), MaxSimError>;
}
pub trait Erase<T: Copy> {
type Output;
fn erase<K: MaxSimKernel<T> + 'static>(self, kernel: K) -> Self::Output;
}
#[derive(Debug, Clone, Copy)]
pub struct BoxErase;
impl<T: Copy + 'static> Erase<T> for BoxErase {
type Output = Box<dyn MaxSimKernel<T>>;
fn erase<K: MaxSimKernel<T> + 'static>(self, kernel: K) -> Self::Output {
Box::new(kernel)
}
}