2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2014-05-06 01:56:44 +00:00
|
|
|
|
2013-10-21 07:50:09 +00:00
|
|
|
struct X {
|
2015-03-26 00:06:52 +00:00
|
|
|
a: isize
|
2013-10-21 07:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trait Changer {
|
2016-10-22 00:33:36 +00:00
|
|
|
fn change(self: Box<Self>) -> Box<Self>;
|
2013-10-21 07:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Changer for X {
|
2014-07-08 06:19:35 +00:00
|
|
|
fn change(mut self: Box<X>) -> Box<X> {
|
2013-10-21 07:50:09 +00:00
|
|
|
self.a = 55;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2021-08-25 00:39:40 +00:00
|
|
|
let x: Box<_> = Box::new(X { a: 32 });
|
2013-10-21 07:50:09 +00:00
|
|
|
let new_x = x.change();
|
|
|
|
assert_eq!(new_x.a, 55);
|
|
|
|
}
|