Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn consume(_: Box<u64>) {}
- let tuple = (Some(Box::new(1)), Some(Box::new(2)));
- match tuple {
- (Some(x), Some(y)) => {
- consume(x);
- consume(y);
- }
- _ => (),
- }
- fn consume(_: Box<u64>) {}
- match [Some(Box::new(1)), Some(Box::new(2))] {
- [Some(x), Some(y)] => {
- consume(x);
- consume(y);
- }
- _ => (),
- }
- fn consume(_: Box<u64>) {}
- let array = [Some(Box::new(1)), Some(Box::new(2))];
- match array {
- [Some(x), Some(y)] => {
- consume(x);
- consume(y);
- }
- _ => (),
- }
- error[E0382]: use of moved value: `(array[..] as std::prelude::v1::Some).0`
- --> src/main.rs:5:24
- |
- 5 | [Some(x), Some(y)] => {
- | - ^ value used here after move
- | |
- | value moved here
- |
- = 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