2014-02-07 13:08:32 -06:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
2013-01-10 17:15:24 -06:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
struct Point {
|
2013-09-26 01:26:09 -05:00
|
|
|
x: f64,
|
|
|
|
y: f64,
|
2013-01-10 17:15:24 -06:00
|
|
|
}
|
|
|
|
|
2014-06-21 05:39:03 -05:00
|
|
|
trait ToString_ {
|
|
|
|
fn to_string(&self) -> String;
|
2014-06-18 08:16:45 -05:00
|
|
|
}
|
|
|
|
|
2014-06-21 05:39:03 -05:00
|
|
|
impl ToString_ for Point {
|
2013-09-26 01:26:09 -05:00
|
|
|
fn new(x: f64, y: f64) -> Point {
|
2014-06-21 05:39:03 -05:00
|
|
|
//~^ ERROR method `new` is not a member of trait `ToString_`
|
2013-01-10 17:15:24 -06:00
|
|
|
Point { x: x, y: y }
|
|
|
|
}
|
|
|
|
|
2014-06-21 05:39:03 -05:00
|
|
|
fn to_string(&self) -> String {
|
2014-02-21 17:41:51 -06:00
|
|
|
format!("({}, {})", self.x, self.y)
|
2013-01-10 17:15:24 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2014-02-21 17:41:51 -06:00
|
|
|
let p = Point::new(0.0, 0.0);
|
2014-06-18 08:16:45 -05:00
|
|
|
//~^ ERROR unresolved name `Point::new`
|
2014-06-19 17:23:51 -05:00
|
|
|
//~^^ ERROR failed to resolve. Use of undeclared module `Point`
|
2014-06-21 05:39:03 -05:00
|
|
|
println!("{}", p.to_string());
|
2013-01-10 17:15:24 -06:00
|
|
|
}
|