Open Nadrieril opened 3 months ago
I propose this alternative API for constructing visitors using a builder pattern. It looks like:
let mut count = 0; let mut visitor = VisitorBuilder::new(&mut count) .on_enter(|state, x: &File| { *state += 1; }) .on_enter(|state, x: &Directory| { *state += 1; }); val.drive(&mut visitor);
This can be more convenient than derives for small visitors with simple state.
The first two commits are nits I happened to find convenient for my usage; I can split them off if desired.
Hey, thanks for your contribution! I like this idea, will review soon
I propose this alternative API for constructing visitors using a builder pattern. It looks like:
This can be more convenient than derives for small visitors with simple state.
The first two commits are nits I happened to find convenient for my usage; I can split them off if desired.