[−][src]Struct source_span::fmt::Formatter
Text formatter with span highlights.
This allows you to format a given input char
stream with highlights and colors (if the
colors
feature is enabled).
A Highlight
is defined by a Span
, a string label and a Style
, and will be rendered
with the stream:
1 | fn main() {
2 | println!("Hello World!")
| ^^^^^^^^^^^^^^ highlighting this string
3 | }
Highlights spans can cover multiple lines and overlap.
See the Highlight
documentation for more informations.
Methods
impl Formatter
[src]
pub fn new() -> Formatter
[src]
Create a new formatter with no highlights.
By default line numbers are showing. You can disable them using the
hide_line_numbers
method.
pub fn show_line_numbers(&mut self)
[src]
Show the line numbers in the output.
This is the default.
pub fn hide_line_numbers(&mut self)
[src]
Hide the line numbers in the output.
By default, line numbers are visible.
pub fn add(&mut self, span: Span, label: Option<String>, style: Style)
[src]
Add a span highlight.
pub fn get<I: Iterator<Item = Result<char>>>(
&self,
input: I,
span: Span
) -> Result<String>
[src]
&self,
input: I,
span: Span
) -> Result<String>
Produce the formatted output.
Create a String
containing the content of the input iterator given span, with the
previously added highlights.
Auto Trait Implementations
impl Sync for Formatter
impl Send for Formatter
impl Unpin for Formatter
impl RefUnwindSafe for Formatter
impl UnwindSafe for Formatter
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,