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