pub struct Rendered<'a> { /* private fields */ }Expand description
A finding prepared for display.
Built with Diagnostic::render style helpers on this type and
then formatted. Without a source buffer it renders the heading and the
labelled details; with one it also quotes and underlines the offending line.
§Examples
use molframe_core::{Code, Diagnostic, Rendered};
let finding = Diagnostic::new(Code::E1106);
let text = Rendered::new(&finding).to_string();
assert!(text.starts_with("error[MOLFRAME-E1106]"));Implementations§
Source§impl<'a> Rendered<'a>
impl<'a> Rendered<'a>
Sourcepub const fn new(finding: &'a Diagnostic) -> Self
pub const fn new(finding: &'a Diagnostic) -> Self
Prepares a finding for display with no source context and no colour.
Sourcepub const fn with_source(self, source: &'a [u8]) -> Self
pub const fn with_source(self, source: &'a [u8]) -> Self
Supplies the bytes the finding was raised against, so the offending line can be quoted.
Sourcepub const fn with_origin(self, origin: &'a str) -> Self
pub const fn with_origin(self, origin: &'a str) -> Self
Names where the input came from, for the location line.
Sourcepub const fn with_color(self, color: bool) -> Self
pub const fn with_color(self, color: bool) -> Self
Enables ANSI colour.
Callers decide this from whether the stream is a terminal and from the user’s own preference; the renderer does not probe the environment.
Trait Implementations§
impl<'a> Copy for Rendered<'a>
Auto Trait Implementations§
impl<'a> Freeze for Rendered<'a>
impl<'a> RefUnwindSafe for Rendered<'a>
impl<'a> Send for Rendered<'a>
impl<'a> Sync for Rendered<'a>
impl<'a> Unpin for Rendered<'a>
impl<'a> UnsafeUnpin for Rendered<'a>
impl<'a> UnwindSafe for Rendered<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more