pub struct Effects(/* private fields */);
Expand description
Implementations§
Source§impl Effects
impl Effects
pub const BOLD: Self = _
pub const DIMMED: Self = _
pub const DOUBLE_UNDERLINE: Self = _
pub const CURLY_UNDERLINE: Self = _
pub const DOTTED_UNDERLINE: Self = _
pub const DASHED_UNDERLINE: Self = _
pub const BLINK: Self = _
pub const HIDDEN: Self = _
Sourcepub const STRIKETHROUGH: Self = _
pub const STRIKETHROUGH: Self = _
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) -> Self
pub const fn insert(self, other: Effects) -> Self
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) -> Self
pub const fn remove(self, other: Effects) -> Self
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) -> Self
pub const fn clear(self) -> Self
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: Self, enable: bool) -> Self
pub const fn set(self, other: Self, enable: bool) -> Self
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: Self)
fn bitor_assign(&mut self, other: Self)
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 PartialOrd for Effects
impl PartialOrd for Effects
Source§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: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read moreimpl Copy for Effects
impl Eq for Effects
impl StructuralPartialEq for Effects
Auto Trait Implementations§
impl Freeze for Effects
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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