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

Extension trait for constructing sections with commonly used formats

Required Methods

Add a header to a Section and indent the body


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.

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"))

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

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