use std::any::type_name;
use std::fmt;
pub enum Filter<Event>
where
Event: Clone + 'static + Send,
{
Pointer(fn(&Event) -> bool),
}
impl<Event> Filter<Event>
where
Event: Clone + 'static + Send,
{
pub(crate) fn call(&mut self, evt: &Event) -> bool {
match self {
Self::Pointer(f) => f(evt),
}
}
}
impl<Event> fmt::Debug for Filter<Event>
where
Event: Clone + 'static + Send,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Pointer(_) => write!(f, "pharos::Filter<{}>::Pointer(_)", type_name::<Event>()),
}
}
}