In a previous post I talked about using Generics instead of OOP for rlox’s Expr representation. This did not work. Instead, I used a sum type:

pub enum Expr<'a> {
    Binary(Box<Expr<'a>>, &'a Token, Box<Expr<'a>>),
    Grouping(Box<Expr<'a>>),
    Literal(Object),
    Unary(&'a Token, Box<Expr<'a>>),
}

There are a lot of Box's involved, which likely means this doesn’t perform well. However, for this first past at least, I’m not going to worry about it too much.