Guest User

Untitled

a guest
Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #![allow(unused)]
  2.  
  3. #[derive(Debug)]
  4. enum Foo {
  5. Bar(Option<u8>),
  6. }
  7.  
  8. fn main() {
  9. let mut foo = Foo::Bar(Some(10));
  10. match &mut foo {
  11. &mut Foo::Bar(ref mut optional) => match optional {
  12. &mut Some(ref mut o) => {
  13. *o = 55;
  14. }
  15. _ => {},
  16. }
  17. _ => {}
  18. };
  19. println!("{:?}", foo);
  20.  
  21.  
  22. let mut foo = Foo::Bar(Some(10));
  23. match &mut foo {
  24. Foo::Bar(optional) => match optional {
  25. Some(o) => {
  26. *o = 55;
  27. }
  28. _ => {},
  29. }
  30. _ => {}
  31. };
  32. println!("{:?}", foo);
  33. }
Add Comment
Please, Sign In to add comment