面试题答案
一键面试use std::fmt;
struct MyStruct {
num: i32,
text: &'static str,
}
impl fmt::Display for MyStruct {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}-{}-{}", self.text, self.num, self.text)
}
}