miette/eyreish/
fmt.rs

1use super::{error::ErrorImpl, ptr::Ref};
2use core::fmt;
3
4impl ErrorImpl<()> {
5    pub(crate) unsafe fn display(this: Ref<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6        this.deref()
7            .handler
8            .as_ref()
9            .map(|handler| handler.display(Self::error(this), f))
10            .unwrap_or_else(|| core::fmt::Display::fmt(Self::diagnostic(this), f))
11    }
12
13    pub(crate) unsafe fn debug(this: Ref<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        this.deref()
15            .handler
16            .as_ref()
17            .map(|handler| handler.debug(Self::diagnostic(this), f))
18            .unwrap_or_else(|| core::fmt::Debug::fmt(Self::diagnostic(this), f))
19    }
20}