2014-01-12 18:59:47 -06:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-01-07 20:53:58 -06:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
|
2014-02-19 20:56:33 -06:00
|
|
|
use std::fmt;
|
|
|
|
|
2014-01-12 18:59:47 -06:00
|
|
|
struct Number {
|
|
|
|
n: i64
|
|
|
|
}
|
|
|
|
|
2015-02-21 05:28:28 -06:00
|
|
|
impl fmt::Display for Number {
|
2014-02-19 20:56:33 -06:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
2014-05-10 16:05:06 -05:00
|
|
|
write!(f, "{}", self.n)
|
2014-01-12 18:59:47 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct List {
|
2014-08-27 20:46:52 -05:00
|
|
|
list: Vec<Box<ToString+'static>> }
|
2014-01-12 18:59:47 -06:00
|
|
|
|
|
|
|
impl List {
|
2014-08-27 20:46:52 -05:00
|
|
|
fn push(&mut self, n: Box<ToString+'static>) {
|
2014-01-12 18:59:47 -06:00
|
|
|
self.list.push(n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-02-17 14:41:32 -06:00
|
|
|
let n: Box<_> = box Number { n: 42 };
|
|
|
|
let mut l: Box<_> = box List { list: Vec::new() };
|
2014-01-12 18:59:47 -06:00
|
|
|
l.push(n);
|
2014-06-21 05:39:03 -05:00
|
|
|
let x = n.to_string();
|
2014-02-05 16:33:10 -06:00
|
|
|
//~^ ERROR: use of moved value: `n`
|
2014-01-12 18:59:47 -06:00
|
|
|
}
|