]>
Commit | Line | Data |
---|---|---|
223e47cc | 1 | struct Point { |
1a4d82fc JJ |
2 | x: f64, |
3 | y: f64, | |
223e47cc LB |
4 | } |
5 | ||
1a4d82fc JJ |
6 | trait ToString_ { |
7 | fn to_string(&self) -> String; | |
8 | } | |
9 | ||
10 | impl ToString_ for Point { | |
11 | fn new(x: f64, y: f64) -> Point { | |
12 | //~^ ERROR method `new` is not a member of trait `ToString_` | |
223e47cc LB |
13 | Point { x: x, y: y } |
14 | } | |
15 | ||
1a4d82fc JJ |
16 | fn to_string(&self) -> String { |
17 | format!("({}, {})", self.x, self.y) | |
223e47cc LB |
18 | } |
19 | } | |
20 | ||
21 | fn main() { | |
1a4d82fc | 22 | let p = Point::new(0.0, 0.0); |
46de9a89 | 23 | //~^ ERROR no function or associated item named `new` found for struct `Point` |
a7813a04 | 24 | println!("{}", p.to_string()); |
223e47cc | 25 | } |