pub trait DebugAnsiColored {
    // Required method
    fn fmt_colored(
        &self,
        f: &mut Formatter<'_>,
        color_scheme: &'static AnsiColorScheme
    ) -> FmtResult;
}
Expand description

An utility alternative core::fmt::Debug trait which can used for colored context formatting.

This trait is not intended to be used directly. It is used for coloring functions and arguments data returned by macros like build_unwind_context_data or unwind_context instead.

§Examples

use unwind_context::{are_colors_enabled, unwind_context, DebugAnsiColored};

fn fmt_example(writer: core::fmt::Write, value: impl Debug + DebugAnsiColored) {
    if are_colors_enabled() {
        let _ = writeln!(
            "{:?}",
            AnsiColored::new(value, &unwind_context::DEFAULT_DEFAULT_COLOR_SCHEME)
        );
    } else {
        let _ = writeln!("{value:?}");
    }
}

Required Methods§

source

fn fmt_colored( &self, f: &mut Formatter<'_>, color_scheme: &'static AnsiColorScheme ) -> FmtResult

Formats the value using with colorization and a given AnsiColorScheme.

§Errors

This function will return an error if the value formatting fails.

Implementations on Foreign Types§

source§

impl<T> DebugAnsiColored for &T

source§

fn fmt_colored( &self, f: &mut Formatter<'_>, color_scheme: &'static AnsiColorScheme ) -> FmtResult

Implementors§