Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #[derive(Debug)]
  2. enum AnnotationType {
  3. A { a: u16 },
  4. B { b: u32, c: u64 }
  5. }
  6.  
  7.  
  8. fn main() {
  9. println!("Hello, world!");
  10. let mut x: AnnotationType = AnnotationType::A { a: 12 };
  11. test(&mut x);
  12. println!("{:?}", x);
  13.  
  14. x = AnnotationType::B { b: 13, c: 15 };
  15. test(&mut x);
  16. println!("{:?}", x);
  17. }
  18.  
  19. fn test(f: &mut AnnotationType) {
  20. match f {
  21. AnnotationType::A { mut a } => { a = 5 },
  22. AnnotationType::B { mut b, mut c } => { b = 13; c = 15 },
  23. };
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement