Enum source_span::fmt::Style

source ·
pub enum Style {
    Error,
    Warning,
    Note,
    Custom(char, char, Color),
}
Expand description

Highlight format description.

Specifies how the highlight should be rendered:

  • What character to use to draw the line under one-lined highlights.
1 | fn main() {
2 |     println!("Hello World!")
  |              ++++++++++++++ highlighting this string
3 | }

In this example, the line character is +.

  • What boundary marker character to use to point the first and last elements of a multi-line highlight.
1 |   fn main() {
  |  ___________^
2 | |     println!("Hello World!")
3 | | }
  | |_^ this span covers more than one line

In this example, the boundary marker is ^. The line character is not used.

§Colors

If the colors feature is enabled, it is also possible to set a color to draw the lines. This will also make the highlights more bright (or bold), along with the line numbers.

Variants§

§

Error

Red curvy underline.

§

Warning

Yellow curvy underline.

§

Note

Blue straight underline.

§

Custom(char, char, Color)

Custom highlight format.

Specifies the line character, the boundary marker and the color (if the colors feature is enabled) used to render the highlight.

Implementations§

source§

impl Style

source

pub fn new(line: char, marker: char, color: Color) -> Style

Create a new custom highlight style.

The line character is user to draw the line under the span elements. The marker character is used to point to the first and last elements of the span when relevant.

source

pub fn line(&self) -> char

The character used to draw the line under the span elements.

source

pub fn marker(&self) -> char

The character used to point the first and last element of the span when relevant.

source

pub fn color(&self) -> Color

Get the color used to draw the highlight.

Trait Implementations§

source§

impl Clone for Style

source§

fn clone(&self) -> Style

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl PartialEq for Style

source§

fn eq(&self, other: &Style) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Style

source§

impl Eq for Style

source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnwindSafe for Style

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.