blob: b8f1650fcdc599bf5d4524f552c5d57cfbc4d245 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#![feature(box_patterns)]
use std::ops::Add;
#[derive(Clone)]
struct Foo(Box<usize>);
impl Add for Foo {
type Output = Foo;
fn add(self, f: Foo) -> Foo {
let Foo(box i) = self;
let Foo(box j) = f;
Foo(Box::new(i + j))
}
}
fn main() {
let x = Foo(Box::new(3));
let _y = {x} + x.clone(); // the `{x}` forces a move to occur
//~^ ERROR borrow of moved value: `x`
}
|