This commit is contained in:
2020-11-03 18:27:31 -07:00
parent b8668163e1
commit 32d7a65228

View File

@@ -99,6 +99,14 @@ impl fmt::Display for Point {
impl OutlinePrint for Point {} impl OutlinePrint for Point {}
struct Wrapper(Vec<String>);
impl fmt::Display for Wrapper {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{}]", self.0.join(", "))
}
}
fn main() { fn main() {
assert_eq!( assert_eq!(
Point { x: 1, y: 0 } + Point { x: 2, y: 3 }, Point { x: 1, y: 0 } + Point { x: 2, y: 3 },
@@ -119,5 +127,8 @@ fn main() {
let xy = Point { x: 344, y: 576 }; let xy = Point { x: 344, y: 576 };
xy.outline_print(); xy.outline_print();
println!("{}", Point {x: 34, y:45}) println!("{}", Point {x: 34, y:45});
let w = Wrapper(vec![String::from("hello"), String::from("world")]);
println!("w = {}", w);
} }