2 ms·
I think this would be more idiomatic for your enum, and also shows how to match on a Box: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gi
by wpwoodjr 6y ago
I think this would be more idiomatic for your enum, and also shows how to match on a Box:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=5365c8f9d02d52b9f4ea523fcacecee6 https://play.rust-lang.org/?version=stable&mode=debug&editio...
#[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!()
};
}