summaryrefslogtreecommitdiffstats
path: root/tests/ui/self/uniq-self-in-mut-slot.rs
blob: 71e57d8c1fa1b50471bb621acf9b07b5ae3a0b25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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);
}