clap::builder::styling

Struct Effects

Source
pub struct Effects(/* private fields */);
Expand description

A set of text effects

§Examples

let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;

Implementations§

Source§

impl Effects

Source

pub const BOLD: Effects = _

Source

pub const DIMMED: Effects = _

Source

pub const ITALIC: Effects = _

Not widely supported. Sometimes treated as inverse or blink

Source

pub const UNDERLINE: Effects = _

Style extensions exist for Kitty, VTE, mintty and iTerm2.

Source

pub const DOUBLE_UNDERLINE: Effects = _

Source

pub const CURLY_UNDERLINE: Effects = _

Source

pub const DOTTED_UNDERLINE: Effects = _

Source

pub const DASHED_UNDERLINE: Effects = _

Source

pub const INVERT: Effects = _

Swap foreground and background colors; inconsistent emulation

Source

pub const HIDDEN: Effects = _

Source

pub const STRIKETHROUGH: Effects = _

Characters legible but marked as if for deletion. Not supported in Terminal.app

Source

pub const fn new() -> Effects

No effects enabled

§Examples
let effects = anstyle::Effects::new();
Source

pub const fn is_plain(self) -> bool

Check if no effects are enabled

§Examples
let effects = anstyle::Effects::new();
assert!(effects.is_plain());

let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert!(!effects.is_plain());
Source

pub const fn contains(self, other: Effects) -> bool

Returns true if all of the effects in other are contained within self.

§Examples
let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert!(effects.contains(anstyle::Effects::BOLD));

let effects = anstyle::Effects::new();
assert!(!effects.contains(anstyle::Effects::BOLD));
Source

pub const fn insert(self, other: Effects) -> Effects

Inserts the specified effects in-place.

§Examples
let effects = anstyle::Effects::new().insert(anstyle::Effects::new());
assert!(effects.is_plain());

let effects = anstyle::Effects::new().insert(anstyle::Effects::BOLD);
assert!(effects.contains(anstyle::Effects::BOLD));
Source

pub const fn remove(self, other: Effects) -> Effects

Removes the specified effects in-place.

§Examples
let effects = (anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE).remove(anstyle::Effects::BOLD);
assert!(!effects.contains(anstyle::Effects::BOLD));
assert!(effects.contains(anstyle::Effects::UNDERLINE));
Source

pub const fn clear(self) -> Effects

Reset all effects in-place

let effects = (anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE).clear();
assert!(!effects.contains(anstyle::Effects::BOLD));
assert!(!effects.contains(anstyle::Effects::UNDERLINE));
Source

pub const fn set(self, other: Effects, enable: bool) -> Effects

Enable or disable the specified effects depending on the passed value.

§Examples
let effects = anstyle::Effects::new().set(anstyle::Effects::BOLD, true);
assert!(effects.contains(anstyle::Effects::BOLD));
Source

pub fn iter(self) -> EffectIter

Iterate over enabled effects

Source

pub fn render(self) -> impl Display + Copy

Render the ANSI code

Trait Implementations§

Source§

impl BitOr<Effects> for Style

§Examples

let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
Source§

type Output = Style

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Effects) -> Style

Performs the | operation. Read more
Source§

impl BitOr for Effects

§Examples

let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
Source§

type Output = Effects

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Effects) -> Effects

Performs the | operation. Read more
Source§

impl BitOrAssign<Effects> for Style

§Examples

let mut style = anstyle::Style::new();
style |= anstyle::Effects::BOLD.into();
Source§

fn bitor_assign(&mut self, other: Effects)

Performs the |= operation. Read more
Source§

impl BitOrAssign for Effects

§Examples

let mut effects = anstyle::Effects::BOLD;
effects |= anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
Source§

fn bitor_assign(&mut self, other: Effects)

Performs the |= operation. Read more
Source§

impl Clone for Effects

Source§

fn clone(&self) -> Effects

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 Debug for Effects

§Examples

let effects = anstyle::Effects::new();
assert_eq!(format!("{:?}", effects), "Effects()");

let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Effects

Source§

fn default() -> Effects

Returns the “default value” for a type. Read more
Source§

impl From<Effects> for Style

§Examples

let style: anstyle::Style = anstyle::Effects::BOLD.into();
Source§

fn from(effects: Effects) -> Style

Converts to this type from the input type.
Source§

impl Hash for Effects

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Effects

Source§

fn cmp(&self, other: &Effects) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<Effects> for Style

§Examples

let effects = anstyle::Effects::BOLD;
assert_eq!(anstyle::Style::new().effects(effects), effects);
assert_ne!(anstyle::Effects::UNDERLINE | effects, effects);
assert_ne!(anstyle::RgbColor(0, 0, 0).on_default() | effects, effects);
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Effects

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Effects

Source§

fn partial_cmp(&self, other: &Effects) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Effects> for Style

§Examples

let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
Source§

type Output = Style

The resulting type after applying the - operator.
Source§

fn sub(self, other: Effects) -> Style

Performs the - operation. Read more
Source§

impl Sub for Effects

§Examples

let effects = (anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE) - anstyle::Effects::BOLD;
assert_eq!(format!("{:?}", effects), "Effects(UNDERLINE)");
Source§

type Output = Effects

The resulting type after applying the - operator.
Source§

fn sub(self, other: Effects) -> Effects

Performs the - operation. Read more
Source§

impl SubAssign<Effects> for Style

§Examples

let mut style = anstyle::Style::new().bold().underline();
style -= anstyle::Effects::BOLD.into();
Source§

fn sub_assign(&mut self, other: Effects)

Performs the -= operation. Read more
Source§

impl SubAssign for Effects

§Examples

let mut effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
effects -= anstyle::Effects::BOLD;
assert_eq!(format!("{:?}", effects), "Effects(UNDERLINE)");
Source§

fn sub_assign(&mut self, other: Effects)

Performs the -= operation. Read more
Source§

impl Copy for Effects

Source§

impl Eq for Effects

Source§

impl StructuralPartialEq for Effects

Auto Trait Implementations§

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§

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

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

Source§

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

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 2 bytes