[−][src]Struct annotate_snippets::formatter::DisplayListFormatter
DisplayListFormatter' constructor accepts two arguments:
color
allows the formatter to optionally apply colors and emphasis using theansi_term
crate.anonymized_line_numbers
will replace line numbers in the left column with the textLL
.
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
impl !Sync for DisplayListFormatter
impl !Send for DisplayListFormatter
impl Unpin for DisplayListFormatter
impl !RefUnwindSafe for DisplayListFormatter
impl !UnwindSafe for DisplayListFormatter
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,