Struct annotate_snippets::formatter::DisplayListFormatter [] [src]

pub struct DisplayListFormatter { /* fields omitted */ }

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

Methods

impl DisplayListFormatter
[src]

[src]

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

[src]

Formats a DisplayList into a String.

Trait Implementations

Auto Trait Implementations