pub struct Effects(/* private fields */);
Expand description
Implementations§
source§impl Effects
impl Effects
pub const BOLD: Effects = _
pub const DIMMED: Effects = _
pub const DOUBLE_UNDERLINE: Effects = _
pub const CURLY_UNDERLINE: Effects = _
pub const DOTTED_UNDERLINE: Effects = _
pub const DASHED_UNDERLINE: Effects = _
pub const BLINK: Effects = _
pub const HIDDEN: Effects = _
sourcepub const STRIKETHROUGH: Effects = _
pub const STRIKETHROUGH: Effects = _
Characters legible but marked as if for deletion. Not supported in Terminal.app
sourcepub const fn is_plain(self) -> bool
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());
sourcepub const fn contains(self, other: Effects) -> bool
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));
sourcepub const fn insert(self, other: Effects) -> Effects
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));
sourcepub const fn remove(self, other: Effects) -> Effects
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));
sourcepub const fn clear(self) -> Effects
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));
sourcepub const fn set(self, other: Effects, enable: bool) -> Effects
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));
sourcepub fn iter(self) -> EffectIter ⓘ
pub fn iter(self) -> EffectIter ⓘ
Iterate over enabled effects
Trait Implementations§
source§impl BitOr<Effects> for Style
impl BitOr<Effects> for Style
Examples
let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
source§impl BitOr for Effects
impl BitOr for Effects
Examples
let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
source§impl BitOrAssign<Effects> for Style
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)
fn bitor_assign(&mut self, other: Effects)
Performs the
|=
operation. Read moresource§impl BitOrAssign for Effects
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)
fn bitor_assign(&mut self, other: Effects)
Performs the
|=
operation. Read moresource§impl Debug for Effects
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§impl From<Effects> for Style
impl From<Effects> for Style
Examples
let style: anstyle::Style = anstyle::Effects::BOLD.into();
source§impl Ord for Effects
impl Ord for Effects
source§impl PartialEq<Effects> for Style
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§impl PartialEq for Effects
impl PartialEq for Effects
source§impl PartialOrd for Effects
impl PartialOrd for Effects
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<Effects> for Style
impl Sub<Effects> for Style
Examples
let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
source§impl Sub for Effects
impl Sub for Effects
Examples
let effects = (anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE) - anstyle::Effects::BOLD;
assert_eq!(format!("{:?}", effects), "Effects(UNDERLINE)");
source§impl SubAssign<Effects> for Style
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)
fn sub_assign(&mut self, other: Effects)
Performs the
-=
operation. Read moresource§impl SubAssign for Effects
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)
fn sub_assign(&mut self, other: Effects)
Performs the
-=
operation. Read moreimpl Copy for Effects
impl Eq for Effects
impl StructuralEq for Effects
impl StructuralPartialEq for Effects
Auto Trait Implementations§
impl RefUnwindSafe for Effects
impl Send for Effects
impl Sync for Effects
impl Unpin for Effects
impl UnwindSafe for Effects
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more