2015-01-07 18:53:58 -08:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2014-02-19 18:56:33 -08:00
|
|
|
use std::fmt;
|
|
|
|
|
2014-01-12 19:59:47 -05:00
|
|
|
struct Number {
|
|
|
|
n: i64
|
|
|
|
}
|
|
|
|
|
2015-02-21 13:28:28 +02:00
|
|
|
impl fmt::Display for Number {
|
2014-02-19 18:56:33 -08:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2014-05-10 14:05:06 -07:00
|
|
|
write!(f, "{}", self.n)
|
2014-01-12 19:59:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct List {
|
2014-08-27 21:46:52 -04:00
|
|
|
list: Vec<Box<ToString+'static>> }
|
2014-01-12 19:59:47 -05:00
|
|
|
|
|
|
|
impl List {
|
2014-08-27 21:46:52 -04:00
|
|
|
fn push(&mut self, n: Box<ToString+'static>) {
|
2014-01-12 19:59:47 -05:00
|
|
|
self.list.push(n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-02-17 21:41:32 +01:00
|
|
|
let n: Box<_> = box Number { n: 42 };
|
|
|
|
let mut l: Box<_> = box List { list: Vec::new() };
|
2014-01-12 19:59:47 -05:00
|
|
|
l.push(n);
|
2014-06-21 03:39:03 -07:00
|
|
|
let x = n.to_string();
|
2019-04-22 08:40:08 +01:00
|
|
|
//~^ ERROR: borrow of moved value: `n`
|
2014-01-12 19:59:47 -05:00
|
|
|
}
|