name: String, location: String, rating: usize, } impl std::fmt::Display for Restaurant { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f,"{}({}): {}", self.name, self.location, "★".repeat(self.rating) ) } } DebugとDisplay 11 let r = Restaurant { name: "Diner matsu7874".to_string(), location: "Tokyo".to_string(), rating: 5, }; println!("{:?}", r); //=> Restaurant { name: "Diner matsu7874", location: "Tokyo", rating: 5 } println!("{}", r); //=> Diner matsu7874(Tokyo): ★★★★★