Extra activity in hello/print/print_display
This commit is contained in:
parent
8d0699fb7a
commit
5568eb4409
@ -21,6 +21,18 @@ impl fmt::Display for Point2D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Complex {
|
||||||
|
real: f64,
|
||||||
|
imag: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Complex {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{} + {}i", self.real, self.imag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let minmax = MinMax(0, 14);
|
let minmax = MinMax(0, 14);
|
||||||
|
|
||||||
@ -42,4 +54,13 @@ fn main() {
|
|||||||
println!("Compare points:");
|
println!("Compare points:");
|
||||||
println!("Display: {}", point);
|
println!("Display: {}", point);
|
||||||
println!("Debug: {:?}", point);
|
println!("Debug: {:?}", point);
|
||||||
|
|
||||||
|
let cmplx = Complex {
|
||||||
|
real: 3.3,
|
||||||
|
imag: 7.2,
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Compare complexes:");
|
||||||
|
println!("Display: {}", cmplx);
|
||||||
|
println!("Debug: {:?}", cmplx);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user