Skip to main content

Style

Struct Style 

Source
pub struct Style { /* private fields */ }
Expand description

ANSI style configuration

Represents a text style with ANSI escape codes for coloring terminal output.

Implementations§

Source§

impl Style

Source

pub const RESET: &'static str = "\x1b[0m"

ANSI reset code to clear all styles

Source

pub const RED: Self

Red color style

Source

pub const GREEN: Self

Green color style

Source

pub const YELLOW: Self

Yellow color style

Source

pub const BLUE: Self

Blue color style

Source

pub const MAGENTA: Self

Magenta color style

Source

pub const CYAN: Self

Cyan color style

Source

pub const BOLD: Self

Bold text style

Source

pub const DIM: Self

Dim/faint text style

Source

pub fn paint(&self, text: &str) -> String

Applies this style to the given text

The style is only applied if colors are enabled (stdout is a TTY and NO_COLOR is not set).

§Arguments
  • text - The text to style
§Returns

The styled text if colors are enabled, otherwise the original text

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin 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> 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>,

Source§

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>,

Source§

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.