diff --git a/src/main.rs b/src/main.rs index 414357f..8a7ef57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,6 +99,14 @@ impl fmt::Display for Point { impl OutlinePrint for Point {} +struct Wrapper(Vec); + +impl fmt::Display for Wrapper { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "[{}]", self.0.join(", ")) + } +} + fn main() { assert_eq!( Point { x: 1, y: 0 } + Point { x: 2, y: 3 }, @@ -119,5 +127,8 @@ fn main() { let xy = Point { x: 344, y: 576 }; 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); }