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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Test file for doc comments inside impl blocks
struct Point {
x: float,
y: float,
}
impl Point {
/// Creates a new Point at the origin.
fn zero() -> Point {
Point { x: 0.0, y: 0.0 }
}
/// Creates a new Point with the given coordinates.
fn new(x: float, y: float) -> Point {
Point { x: x, y: y }
}
/// Calculates the distance from the origin.
fn distance_from_origin(self) -> float {
(self.x * self.x + self.y * self.y).sqrt()
}
}