use brk_traversable::Traversable; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use super::{Filter, Term}; #[derive(Default, Clone, Traversable)] pub struct ByTerm { pub short: T, pub long: T, } impl ByTerm { pub fn new(mut create: F) -> Self where F: FnMut(Filter) -> T, { Self { short: create(Filter::Term(Term::Sth)), long: create(Filter::Term(Term::Lth)), } } pub fn iter(&self) -> impl Iterator { [&self.short, &self.long].into_iter() } pub fn iter_mut(&mut self) -> impl Iterator { [&mut self.short, &mut self.long].into_iter() } pub fn par_iter(&self) -> impl ParallelIterator where T: Send + Sync, { [&self.short, &self.long].into_par_iter() } pub fn par_iter_mut(&mut self) -> impl ParallelIterator where T: Send + Sync, { [&mut self.short, &mut self.long].into_par_iter() } }