mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
23 lines
331 B
Rust
23 lines
331 B
Rust
//@ run-pass
|
|
|
|
struct X {
|
|
a: isize
|
|
}
|
|
|
|
trait Changer {
|
|
fn change(self: Box<Self>) -> Box<Self>;
|
|
}
|
|
|
|
impl Changer for X {
|
|
fn change(mut self: Box<X>) -> Box<X> {
|
|
self.a = 55;
|
|
self
|
|
}
|
|
}
|
|
|
|
pub fn main() {
|
|
let x: Box<_> = Box::new(X { a: 32 });
|
|
let new_x = x.change();
|
|
assert_eq!(new_x.a, 55);
|
|
}
|