blob: fb21ab13ec307f6283012ef4a2b6462c6cfeb657 (
plain) (
tree)
|
|
use std::fmt::{Show,Formatter,FormatError};
struct Point {
x: int,
y: int,
}
impl Show for Point {
fn fmt (&self, f: &mut Formatter) -> Result<(), FormatError> {
try!(write!(f, "({}, {})", self.x, self.y));
return Ok(());
}
}
fn main () {
let p1 = Point { x: 1, y: 2 };
println!("{}", p1);
}
|