2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2013-10-21 02:50:09 -05:00
|
|
|
struct X {
|
2015-03-25 19:06:52 -05:00
|
|
|
a: isize
|
2013-10-21 02:50:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
trait Changer {
|
2016-10-21 19:33:36 -05:00
|
|
|
fn change(self) -> Self;
|
2013-10-21 02:50:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Changer for X {
|
|
|
|
fn change(mut self) -> X {
|
|
|
|
self.a = 55;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let x = X { a: 32 };
|
|
|
|
let new_x = x.change();
|
|
|
|
assert_eq!(new_x.a, 55);
|
|
|
|
}
|