Start work on a SyntaxMap data structure

This commit is contained in:
Max Brunsfeld 2022-08-05 14:58:45 -07:00
parent 6e67448420
commit f6a817a0f3
7 changed files with 476 additions and 4 deletions

View file

@ -608,9 +608,9 @@ where
impl<'a, F, T, S, U> Iterator for FilterCursor<'a, F, T, U>
where
F: Fn(&T::Summary) -> bool,
F: FnMut(&T::Summary) -> bool,
T: Item<Summary = S>,
S: Summary<Context = ()>,
S: Summary<Context = ()>, //Context for the summary must be unit type, as .next() doesn't take arguments
U: Dimension<'a, T::Summary>,
{
type Item = &'a T;
@ -621,7 +621,7 @@ where
}
if let Some(item) = self.item() {
self.cursor.next_internal(&self.filter_node, &());
self.cursor.next_internal(&mut self.filter_node, &());
Some(item)
} else {
None

View file

@ -168,6 +168,8 @@ impl<T: Item> SumTree<T> {
Cursor::new(self)
}
/// Note: If the summary type requires a non `()` context, then the filter cursor
/// that is returned cannot be used with Rust's iterators.
pub fn filter<'a, F, U>(&'a self, filter_node: F) -> FilterCursor<F, T, U>
where
F: FnMut(&T::Summary) -> bool,