blob: 76487ef1c14093d604ebe1ba72d7727e7e410ec1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#![feature(box_syntax)]
use std::fmt;
struct Number {
n: i64
}
impl fmt::Display for Number {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.n)
}
}
struct List {
list: Vec<Box<dyn ToString + 'static>> }
impl List {
fn push(&mut self, n: Box<dyn ToString + 'static>) {
self.list.push(n);
}
}
fn main() {
let n: Box<_> = box Number { n: 42 };
let mut l: Box<_> = box List { list: Vec::new() };
l.push(n);
let x = n.to_string();
//~^ ERROR: borrow of moved value: `n`
}
|