pub trait SectionExt: Sized {
    // Required method
    fn header<C>(self, header: C) -> IndentedSection<C, Self>
       where C: Display + Send + Sync + 'static;
}
Expand description

Extension trait for constructing sections with commonly used formats

Required Methods§

source

fn header<C>(self, header: C) -> IndentedSection<C, Self>
where C: Display + Send + Sync + 'static,

Add a header to a Section and indent the body

Details

Bodies are always indented to the same level as error messages and spans. The header is not printed if the display impl of the body produces no output.

Examples
use color_eyre::{eyre::eyre, Section, SectionExt, eyre::Report};

let all_in_header = "header\n   body\n   body";
let report = Err::<(), Report>(eyre!("an error occurred"))
    .section(all_in_header)
    .unwrap_err();

let just_header = "header";
let just_body = "body\nbody";
let report2 = Err::<(), Report>(eyre!("an error occurred"))
    .section(just_body.header(just_header))
    .unwrap_err();

assert_eq!(format!("{:?}", report), format!("{:?}", report2))

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> SectionExt for T
where T: Display + Send + Sync + 'static,