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

pub struct DisplayListFormatter { /* fields omitted */ }

DisplayListFormatter' constructor accepts two arguments:

  • color allows the formatter to optionally apply colors and emphasis using the ansi_term crate.
  • anonymized_line_numbers will replace line numbers in the left column with the text LL.

Example:

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

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

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]

pub fn new(color: bool, anonymized_line_numbers: bool) -> Self[src]

Constructor for the struct.

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

The argument anonymized_line_numbers will replace line numbers in the left column with the text LL. This can be useful to enable when running UI tests, such as in the Rust test suite.

pub fn format(&self, dl: &DisplayList) -> String[src]

Formats a DisplayList into a String.

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]