pub struct DisplayListFormatter { /* private fields */ }
Expand description

DisplayListFormatter’ constructor accepts a single argument which allows the formatter to optionally apply colors and emphasis using ansi_term crate.

Example:

use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::display_list::{DisplayList, DisplayLine, DisplaySourceLine};

let dlf = DisplayListFormatter::new(false); // Don't use colors

let dl = DisplayList {
    body: vec![
        DisplayLine::Source {
            lineno: Some(192),
            inline_marks: vec![],
            line: DisplaySourceLine::Content {
                text: "Example line of text".into(),
                range: (0, 21)
            }
        }
    ]
};
assert_eq!(dlf.format(&dl), "192 | Example line of text");

Implementations§

Constructor for the struct. The argument color selects the stylesheet depending on the user preferences and ansi_term crate availability.

Formats a DisplayList into a String.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.