use std::rc::Rc; #[derive(Clone, Debug)] pub enum Value { Int(i32), String(Rc), Null, } impl Default for Value { fn default() -> Value { Value::Null } } impl Value { pub fn unwrap_int(&self) -> i32 { match self { Value::Int(i) => *i, _ => panic!("Attempt to unwrap Int; found {:?}", self), } } pub fn unwrap_string(&self) -> &Rc { match self { Value::String(s) => s, _ => panic!("Attempt to unwrap String; found {:?}", self), } } }