1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{error::ErrorImpl, ptr::RefPtr};
use core::fmt;

impl ErrorImpl<()> {
    pub(crate) fn display(this: RefPtr<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        ErrorImpl::header(this)
            .handler
            .as_ref()
            .map(|handler| handler.display(Self::error(this), f))
            .unwrap_or_else(|| core::fmt::Display::fmt(Self::error(this), f))
    }

    /// Debug formats the error using the captured handler
    pub(crate) fn debug(this: RefPtr<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        ErrorImpl::header(this)
            .handler
            .as_ref()
            .map(|handler| handler.debug(Self::error(this), f))
            .unwrap_or_else(|| core::fmt::Debug::fmt(Self::error(this), f))
    }
}