Struct source_span::fmt::Formatter
source · pub struct Formatter { /* private fields */ }Expand description
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.
Implementations§
source§impl Formatter
impl Formatter
sourcepub fn new() -> Formatter
pub fn new() -> Formatter
Create a new formatter with no highlights.
By default line numbers are showing. You can disable them using the
hide_line_numbers method.
sourcepub fn show_line_numbers(&mut self)
pub fn show_line_numbers(&mut self)
Show the line numbers in the output.
This is the default.
sourcepub fn hide_line_numbers(&mut self)
pub fn hide_line_numbers(&mut self)
Hide the line numbers in the output.
By default, line numbers are visible.
Auto Trait Implementations§
impl Freeze for Formatter
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnwindSafe for Formatter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more