Struct Effects

pub struct Effects(/* private field */);

A set of text effects

Examples

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

Implementations

impl Effects

const BOLD: Self = _;
const DIMMED: Self = _;
const ITALIC: Self = _;

Not widely supported. Sometimes treated as inverse or blink

const UNDERLINE: Self = _;

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

const DOUBLE_UNDERLINE: Self = _;
const CURLY_UNDERLINE: Self = _;
const DOTTED_UNDERLINE: Self = _;
const DASHED_UNDERLINE: Self = _;
const INVERT: Self = _;

Swap foreground and background colors; inconsistent emulation

const HIDDEN: Self = _;
const STRIKETHROUGH: Self = _;

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

const fn new() -> Self

No effects enabled

Examples

let effects = anstyle::Effects::new();
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());
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));
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));
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));
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));
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));
fn iter(self) -> EffectIter

Iterate over enabled effects

fn render(self) -> impl Display + Copy

Render the ANSI code

Trait Implementations

impl BitOr for Effects

type Output = Effects;
fn bitor(self, rhs: Self) -> Self

impl BitOrAssign for Effects

fn bitor_assign(&mut self, other: Self)

impl Clone for Effects

fn clone(&self) -> Effects

impl Copy for Effects

impl Debug for Effects

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

impl Default for Effects

fn default() -> Effects

impl Eq for Effects

impl Hash for Effects

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

impl Ord for Effects

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

impl PartialEq for Effects

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

impl PartialOrd for Effects

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

impl StructuralPartialEq for Effects

impl Sub for Effects

type Output = Effects;
fn sub(self, other: Self) -> Self

impl SubAssign for Effects

fn sub_assign(&mut self, other: Self)

Auto Trait Implementations

impl Freeze for Effects

impl RefUnwindSafe for Effects

impl Send for Effects

impl Sync for Effects

impl Unpin for Effects

impl UnsafeUnpin for Effects

impl UnwindSafe for Effects

Blanket Implementations

impl<T> Any for Effects where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Effects where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Effects where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Effects where T: Clone,

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

impl<T> From<T> for Effects

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Effects where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Effects where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Effects where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Effects where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>