I think this would be more idiomatic for your enum, and also shows how to match on a Box: play.rust-lang.org/?version=stable...
#[derive(Debug)] pub enum Expr_ { Let(String, Expr, Expr), FnCall(String, Vec<Expr>), Lambda(Vec<String>, Expr), Variable(String), IntLiteral(i32), } use self::Expr_::*; pub type Expr = Box<Expr_>; fn main() { let x = Box::new(Variable("test".to_string())); match *x { Variable(n) => dbg!(n), _ => unimplemented!() }; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think this would be more idiomatic for your enum, and also shows how to match on a Box:
play.rust-lang.org/?version=stable...