Implementing a two line Display
โ Rust ๐ 2025-10-05 ๐ค surdeus ๐๏ธ 7Hey folks,
This is driving me absolutely nuts. This of course doesnโt compile:
impl Display for TestResult {
fn fmt(&self, f: &mut Formatter<'\_>) -> std::fmt::Result {
writeln!(f, "{}", self.main_line())
if let Some(detail_line) = self.detail_line() {
writeln!(f, "{}", detail_line)
}
}
}
How would I do this properly?
Thanks!
10 posts - 5 participants
๐ท๏ธ Rust_feed