defmt/impls/core_/panic.rs
1use core::panic;
2
3use super::*;
4
5impl Format for panic::PanicInfo<'_> {
6 fn format(&self, f: Formatter) {
7 if let Some(location) = self.location() {
8 crate::write!(f, "panicked at {}", location);
9 } else {
10 crate::write!(f, "panicked");
11 }
12 // TODO: consider supporting self.message() once stabilized, or add a crate feature for
13 // conditional support
14 }
15}
16
17impl Format for panic::Location<'_> {
18 fn format(&self, f: Formatter) {
19 crate::write!(
20 f,
21 "{=str}:{=u32}:{=u32}",
22 self.file(),
23 self.line(),
24 self.column()
25 );
26 }
27}