Done with 1.2.2 activities

cat-town
Dan Buch 8 years ago
parent da88fc810d
commit de02f07049
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC

@ -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() { fn main() {
let minmax = MinMax(0, 14); let minmax = MinMax(0, 14);
@ -40,4 +52,10 @@ fn main() {
println!("Compare points:"); println!("Compare points:");
println!("Display: {}", point); println!("Display: {}", point);
println!("Debug: {:?}", point); println!("Debug: {:?}", point);
let compl = Complex { real: 3.3, imag: 7.2 };
println!("Compare complex:");
println!("Display: {}", compl);
println!("Debug: {:?}", compl);
} }

@ -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);
}
}
Loading…
Cancel
Save