mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
16 lines
340 B
Rust
16 lines
340 B
Rust
//@ run-pass
|
|
#![allow(non_camel_case_types)]
|
|
|
|
trait double {
|
|
fn double(self: Box<Self>) -> usize;
|
|
}
|
|
|
|
impl double for Box<usize> {
|
|
fn double(self: Box<Box<usize>>) -> usize { **self * 2 }
|
|
}
|
|
|
|
pub fn main() {
|
|
let x: Box<Box<Box<Box<Box<_>>>>> = Box::new(Box::new(Box::new(Box::new(Box::new(3)))));
|
|
assert_eq!(x.double(), 6);
|
|
}
|