Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug, Serialize)]
- enum ArithExp{
- Sum{
- lhs: Box<ArithExp>,
- rhs: Box<ArithExp>
- },
- Mul {
- lhs: Box<ArithExp>,
- rhs: Box<ArithExp>
- },
- Num {
- value: f64
- },
- }
- fn num(value: f64) -> std::boxed::Box<ArithExp>{
- Box::new(ArithExp::Num { value })
- }
- fn main() {
- let number = num(1.0);
- match *number {
- ArithExp::Num{value} => println!("VALUE = {}", value),
- _ => ()
- }
- println!("{:?}", number);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement