rust/tests/ui/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
340 B
Rust
Raw Normal View History

//@ 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 }
2012-06-20 03:52:33 +00:00
}
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);
2012-06-20 03:52:33 +00:00
}