summaryrefslogtreecommitdiffstats
path: root/tests/ui/self/by-value-self-in-mut-slot.rs
blob: 267afd1dcad7fdc7571061d448f2f52c96bcd552 (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) -> Self;
}

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);
}