Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #[derive(Debug, Serialize)]
  2. enum ArithExp{
  3. Sum{
  4. lhs: Box<ArithExp>,
  5. rhs: Box<ArithExp>
  6. },
  7. Mul {
  8. lhs: Box<ArithExp>,
  9. rhs: Box<ArithExp>
  10. },
  11. Num {
  12. value: f64
  13. },
  14. }
  15.  
  16. fn num(value: f64) -> std::boxed::Box<ArithExp>{
  17. Box::new(ArithExp::Num { value })
  18. }
  19.  
  20. fn main() {
  21. let number = num(1.0);
  22. match *number {
  23. ArithExp::Num{value} => println!("VALUE = {}", value),
  24. _ => ()
  25. }
  26. println!("{:?}", number);
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement