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
§Examples
let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
impl BitOr<Effects> for Style
§Examples
let style = anstyle::Style::new() | anstyle::Effects::BOLD.into();
Source§impl BitOr for Effects
§Examples
let effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
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
§Examples
let mut style = anstyle::Style::new();
style |= anstyle::Effects::BOLD.into();
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
§Examples
let mut effects = anstyle::Effects::BOLD;
effects |= anstyle::Effects::UNDERLINE;
assert_eq!(format!("{:?}", effects), "Effects(BOLD | UNDERLINE)");
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
§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)");
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
§Examples
let style: anstyle::Style = anstyle::Effects::BOLD.into();
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
§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);
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
§Examples
let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
impl Sub<Effects> for Style
§Examples
let style = anstyle::Style::new().bold().underline() - anstyle::Effects::BOLD.into();
Source§impl Sub for Effects
§Examples
let effects = (anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE) - anstyle::Effects::BOLD;
assert_eq!(format!("{:?}", effects), "Effects(UNDERLINE)");
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
§Examples
let mut style = anstyle::Style::new().bold().underline();
style -= anstyle::Effects::BOLD.into();
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
§Examples
let mut effects = anstyle::Effects::BOLD | anstyle::Effects::UNDERLINE;
effects -= anstyle::Effects::BOLD;
assert_eq!(format!("{:?}", effects), "Effects(UNDERLINE)");
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 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