pub struct Renderer { /* private fields */ }
Expand description
The caller is expected to detect any relevant terminal features and configure the renderer, including
- ANSI Escape code support (always outputted with
Renderer::styled
) - Terminal width (
Renderer::term_width
) - Unicode support (
Renderer::decor_style
)
§Example
let report = // ...
let renderer = Renderer::styled();
let output = renderer.render(report);
anstream::println!("{output}");
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub const fn styled() -> Self
pub const fn styled() -> Self
Default terminal styling
If ANSI escape codes are not supported, either
- Call
Renderer::plain
instead - Strip them after the fact, like with
anstream
§Note
When testing styled terminal output, see the testing-colors
feature
Sourcepub const fn short_message(self, short_message: bool) -> Self
pub const fn short_message(self, short_message: bool) -> Self
Abbreviate the message
Sourcepub const fn term_width(self, term_width: usize) -> Self
pub const fn term_width(self, term_width: usize) -> Self
Set the width to render within
Affects the rendering of Snippet
s
Sourcepub const fn decor_style(self, decor_style: DecorStyle) -> Self
pub const fn decor_style(self, decor_style: DecorStyle) -> Self
Set the character set used for rendering decor
Sourcepub const fn anonymized_line_numbers(
self,
anonymized_line_numbers: bool,
) -> Self
pub const fn anonymized_line_numbers( self, anonymized_line_numbers: bool, ) -> Self
Anonymize line numbers
When enabled, line numbers are replaced with LL
which is useful for tests.
§Example
--> $DIR/whitespace-trimming.rs:4:193
|
LL | ... let _: () = 42;
| ^^ expected (), found integer
|
Source§impl Renderer
Customize Renderer::styled
impl Renderer
Customize Renderer::styled
Sourcepub const fn context(self, style: Style) -> Self
pub const fn context(self, style: Style) -> Self
Override the output style for AnnotationKind::Context
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Renderer
impl RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnwindSafe for Renderer
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