Guest User

Untitled

a guest
Jun 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. fn consume(_: Box<u64>) {}
  2. let tuple = (Some(Box::new(1)), Some(Box::new(2)));
  3. match tuple {
  4. (Some(x), Some(y)) => {
  5. consume(x);
  6. consume(y);
  7. }
  8. _ => (),
  9. }
  10.  
  11. fn consume(_: Box<u64>) {}
  12. match [Some(Box::new(1)), Some(Box::new(2))] {
  13. [Some(x), Some(y)] => {
  14. consume(x);
  15. consume(y);
  16. }
  17. _ => (),
  18. }
  19.  
  20. fn consume(_: Box<u64>) {}
  21. let array = [Some(Box::new(1)), Some(Box::new(2))];
  22. match array {
  23. [Some(x), Some(y)] => {
  24. consume(x);
  25. consume(y);
  26. }
  27. _ => (),
  28. }
  29.  
  30. error[E0382]: use of moved value: `(array[..] as std::prelude::v1::Some).0`
  31. --> src/main.rs:5:24
  32. |
  33. 5 | [Some(x), Some(y)] => {
  34. | - ^ value used here after move
  35. | |
  36. | value moved here
  37. |
  38. = note: move occurs because the value has type `std::boxed::Box<u64>`, which does not implement the `Copy` trait
Add Comment
Please, Sign In to add comment