Done with 1.2.2 activities

This commit is contained in:
Dan Buch 2016-08-31 10:31:28 -04:00
parent da88fc810d
commit de02f07049
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
2 changed files with 18 additions and 9 deletions

View File

@ -21,6 +21,18 @@ impl fmt::Display for Point2 {
}
}
#[derive(Debug)]
struct Complex {
real: f64,
imag: f64,
}
impl fmt::Display for Complex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "real: {}, imag: {}", self.real, self.imag)
}
}
fn main() {
let minmax = MinMax(0, 14);
@ -40,4 +52,10 @@ fn main() {
println!("Compare points:");
println!("Display: {}", point);
println!("Debug: {:?}", point);
let compl = Complex { real: 3.3, imag: 7.2 };
println!("Compare complex:");
println!("Display: {}", compl);
println!("Debug: {:?}", compl);
}

View File

@ -1,9 +0,0 @@
use std::fmt;
struct Structure(i32);
impl fmt::Display for Structure {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0);
}
}