Closed lovasoa closed 1 year ago
This PR implements two new traits: VisitorMut and DriveMut. It allows mutating the data structure that is being visited.
Here is an example of what is now possible :
#[derive(DriveMut)] struct Chain { next: Option<Box<Chain>>, } #[derive(VisitorMut)] #[visitor(Chain(enter))] struct ChainCutter { cut_at_depth: usize, } impl ChainCutter { fn enter_chain(&mut self, item: &mut Chain) { if self.cut_at_depth == 0 { item.next = None; } else { self.cut_at_depth -= 1; } } }
Closes #8
Great, thanks for merging !
This PR implements two new traits: VisitorMut and DriveMut. It allows mutating the data structure that is being visited.
Here is an example of what is now possible :
Closes #8