Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct PP {
- a: u16
- }
- #[derive(Debug)]
- enum AnnotationType {
- A(PP),
- B { b: u32, c: u64 }
- }
- fn main() {
- println!("Hello, world!");
- let mut pp = PP { a: 123};
- let mut x: AnnotationType = AnnotationType::A(pp);
- test(&mut x);
- println!("{:?}", x);
- x = AnnotationType::B { b: 13, c: 15 };
- test(&mut x);
- println!("{:?}", x);
- }
- fn test(f: &mut AnnotationType) {
- match f {
- AnnotationType::A(ref mut pp) => { pp.a = 5 },
- AnnotationType::B { ref mut b, ref mut c } => { *b = 132; *c = 151 },
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement