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