I found an interesting implementation of the visitor pattern in Rust:
pub trait Visitor<T> {
fn visit(&mut self, t: &T);
}
pub trait Visitable: Sized {
fn accept<T>(&self, t: &mut T)
where
T: Visitor<Self>,
{
t.visit(self);
}
}
As Visitable is not object safe, I'm unable to store a Vec of Visitable objects. I found a solution to a similar problem, would it be possible to do a similar solution for Visitable?