summaryrefslogtreecommitdiffstats
path: root/tests/incremental/change_private_fn_cc/auxiliary/point.rs
blob: 483f205720c95e5a44c3b5bba99fea14ba80ed0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
pub struct Point {
    pub x: f32,
    pub y: f32,
}

fn distance_squared(this: &Point) -> f32 {
    #[cfg(cfail1)]
    return this.x + this.y;

    #[cfg(cfail2)]
    return this.x * this.x + this.y * this.y;
}

impl Point {
    pub fn distance_from_origin(&self) -> f32 {
        distance_squared(self).sqrt()
    }
}

impl Point {
    pub fn translate(&mut self, x: f32, y: f32) {
        self.x += x;
        self.y += y;
    }
}