]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
b7449926 | 11 | // run-pass |
1a4d82fc JJ |
12 | #![feature(box_syntax)] |
13 | ||
223e47cc | 14 | trait Foo { |
1a4d82fc | 15 | fn foo(&self) -> String; |
223e47cc LB |
16 | } |
17 | ||
1a4d82fc JJ |
18 | impl<T:Foo> Foo for Box<T> { |
19 | fn foo(&self) -> String { | |
20 | format!("box {}", (**self).foo()) | |
223e47cc LB |
21 | } |
22 | } | |
23 | ||
c34b1796 | 24 | impl Foo for usize { |
1a4d82fc JJ |
25 | fn foo(&self) -> String { |
26 | format!("{}", *self) | |
223e47cc LB |
27 | } |
28 | } | |
29 | ||
30 | pub fn main() { | |
c34b1796 | 31 | let x: Box<_> = box 3; |
1a4d82fc | 32 | assert_eq!(x.foo(), "box 3".to_string()); |
223e47cc | 33 | } |