Enum source_span::fmt::Style[][src]

pub enum Style {
    Error,
    Warning,
    Note,
    Help,
    Custom(charcharColor),
}
Expand description

Highlight format description.

Specifies how the highlight should be rendered:

  • What character to use to underline highlights.
1 | fn main() {
2 |     println!("Hello World!")
  |              ^++++++++++++^ highlighting this string
3 | }

In this example, the underline character is +.

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

In this example, the boundary marker is ^. Note that the underline 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
Expand description

Red curvy underline.

Warning
Expand description

Yellow curvy underline.

Note
Expand description

Blue straight underline.

Help
Expand description

Green straight underline.

Custom(charcharColor)
Expand description

Custom highlight format.

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

Implementations

impl Style[src]

#[must_use]
pub const fn new(line: char, marker: char, color: Color) -> Self
[src]

Create a new custom highlight style.

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

#[must_use]
pub fn line(&self) -> char
[src]

The character used to underline the highlighted section.

#[must_use]
pub fn marker(&self) -> char
[src]

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

#[must_use]
pub fn color(&self) -> Color
[src]

Get the color used to draw the highlight.

Trait Implementations

impl Clone for Style[src]

fn clone(&self) -> Style[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Copy for Style[src]

Auto Trait Implementations

impl RefUnwindSafe for Style

impl Send for Style

impl Sync for Style

impl Unpin for Style

impl UnwindSafe for Style

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.