| 1 | use crate::{error::ErrorImpl, ptr::RefPtr}; |
| 2 | use core::fmt; |
| 3 | |
| 4 | impl ErrorImpl<()> { |
| 5 | pub(crate) fn display(this: RefPtr<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 6 | ErrorImplOption>::header(this) |
| 7 | .handler |
| 8 | .as_ref() |
| 9 | .map(|handler: &Box| handler.display(Self::error(this), f)) |
| 10 | .unwrap_or_else(|| core::fmt::Display::fmt(Self::error(this), f)) |
| 11 | } |
| 12 | |
| 13 | /// Debug formats the error using the captured handler |
| 14 | pub(crate) fn debug(this: RefPtr<'_, Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 15 | ErrorImplOption>::header(this) |
| 16 | .handler |
| 17 | .as_ref() |
| 18 | .map(|handler: &Box| handler.debug(Self::error(this), f)) |
| 19 | .unwrap_or_else(|| core::fmt::Debug::fmt(Self::error(this), f)) |
| 20 | } |
| 21 | } |
| 22 | |