]> git.proxmox.com Git - rustc.git/blame - src/test/incremental/change_private_fn_cc/auxiliary/point.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / incremental / change_private_fn_cc / auxiliary / point.rs
CommitLineData
bd371182
AL
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
c30ab7b3
SL
11pub struct Point {
12 pub x: f32,
13 pub y: f32,
14}
15
16fn distance_squared(this: &Point) -> f32 {
17 #[cfg(rpass1)]
18 return this.x + this.y;
bd371182 19
c30ab7b3
SL
20 #[cfg(rpass2)]
21 return this.x * this.x + this.y * this.y;
bd371182
AL
22}
23
c30ab7b3
SL
24impl Point {
25 pub fn distance_from_origin(&self) -> f32 {
26 distance_squared(self).sqrt()
bd371182
AL
27 }
28}
29
c30ab7b3
SL
30impl Point {
31 pub fn translate(&mut self, x: f32, y: f32) {
32 self.x += x;
33 self.y += y;
34 }
35}