pub struct Annotations<'a, M> { /* private fields */ }
Expand description

A collection of annotations for a source snippet.

Implementations§

source§

impl<'a, M> Annotations<'a, M>

source

pub fn new(snippet: &'a SourceSnippet, main_style: MainStyle<M>) -> Self

source

pub fn add_annotation( &mut self, span: Range<usize>, style: AnnotStyle<M>, label: Vec<(String, M)> )

source

pub fn max_line_no_width(&self) -> usize

source§

impl<'a, M: Clone> Annotations<'a, M>

source

pub fn render( &self, max_line_no_width: usize, max_fill_after_first: usize, max_fill_before_last: usize ) -> Vec<(String, M)>

Renders the snippet with the annotations.

max_line_no_width should be at least self.max_line_no_width(), but it can be greater to align the margin of multiple snippets.

Trait Implementations§

source§

impl<'a, M: Debug> Debug for Annotations<'a, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, M> Freeze for Annotations<'a, M>
where M: Freeze,

§

impl<'a, M> RefUnwindSafe for Annotations<'a, M>
where M: RefUnwindSafe,

§

impl<'a, M> Send for Annotations<'a, M>
where M: Send,

§

impl<'a, M> Sync for Annotations<'a, M>
where M: Sync,

§

impl<'a, M> Unpin for Annotations<'a, M>
where M: Unpin,

§

impl<'a, M> UnwindSafe for Annotations<'a, M>
where M: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.