1 // run-pass
2 
3 use std::fmt;
4 
5 struct Thingy {
6     x: isize,
7     y: isize
8 }
9 
10 impl fmt::Debug for Thingy {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result11     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12         write!(f, "{{ x: {:?}, y: {:?} }}", self.x, self.y)
13     }
14 }
15 
16 struct PolymorphicThingy<T> {
17     x: T
18 }
19 
20 impl<T:fmt::Debug> fmt::Debug for PolymorphicThingy<T> {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result21     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22         write!(f, "{:?}", self.x)
23     }
24 }
25 
main()26 pub fn main() {
27     println!("{:?}", Thingy { x: 1, y: 2 });
28     println!("{:?}", PolymorphicThingy { x: Thingy { x: 1, y: 2 } });
29 }
30