Skip to main content

TermStyle

Struct TermStyle 

Source
pub struct TermStyle { /* private fields */ }
Available on crate feature term only.
Expand description

๐Ÿฎ– ๐“ โІ A compact set of broadly supported terminal text styles.


๐Ÿ“ sys/os/term

๐Ÿ“ฆ size_of::<TermStyle>() == 1 bytes / 8 bits


Its bits occupy the low byte of TermStyleExt with the same meanings.

Implementationsยง

Sourceยง

impl TermStyle

Source

pub const fn extended(self) -> TermStyleExt

Returns the corresponding extended style set.

Sourceยง

impl TermStyle

Named constants

Source

pub const BOLD: Self

1 Increased intensity.

Source

pub const ITALIC: Self

1 Italic text.

Source

pub const UNDERLINE: Self

1 Underlined text.

Source

pub const DIM: Self

1 Reduced intensity.

1 Blinking text.

Source

pub const INVERSE: Self

1 Swapped foreground and background.

Source

pub const HIDDEN: Self

1 Concealed text.

Source

pub const CROSSED: Self

1 Crossed-out text.

Sourceยง

impl TermStyle

Convenience methods derived from each named constant.

Source

pub const fn has_bold(self) -> bool

Returns true if BOLD is present.

Source

pub const fn contains_bold(self) -> bool

Returns true if all bits in BOLD are present.

Source

pub const fn intersects_bold(self) -> bool

Returns true if the set shares any bit with BOLD.

Source

pub const fn with_bold(self) -> Self

Returns self with BOLD inserted.

Source

pub const fn with_bold_if(self, condition: bool) -> Self

Returns self with BOLD inserted if condition is true.

Source

pub const fn without_bold(self) -> Self

Returns self with BOLD removed.

Source

pub const fn set_bold(&mut self)

Sets BOLD.

Source

pub const fn set_bold_if(&mut self, condition: bool)

Sets BOLD if condition is true.

Source

pub const fn unset_bold(&mut self)

Unsets BOLD.

Source

pub const fn has_italic(self) -> bool

Returns true if ITALIC is present.

Source

pub const fn contains_italic(self) -> bool

Returns true if all bits in ITALIC are present.

Source

pub const fn intersects_italic(self) -> bool

Returns true if the set shares any bit with ITALIC.

Source

pub const fn with_italic(self) -> Self

Returns self with ITALIC inserted.

Source

pub const fn with_italic_if(self, condition: bool) -> Self

Returns self with ITALIC inserted if condition is true.

Source

pub const fn without_italic(self) -> Self

Returns self with ITALIC removed.

Source

pub const fn set_italic(&mut self)

Sets ITALIC.

Source

pub const fn set_italic_if(&mut self, condition: bool)

Sets ITALIC if condition is true.

Source

pub const fn unset_italic(&mut self)

Unsets ITALIC.

Source

pub const fn has_underline(self) -> bool

Returns true if UNDERLINE is present.

Source

pub const fn contains_underline(self) -> bool

Returns true if all bits in UNDERLINE are present.

Source

pub const fn intersects_underline(self) -> bool

Returns true if the set shares any bit with UNDERLINE.

Source

pub const fn with_underline(self) -> Self

Returns self with UNDERLINE inserted.

Source

pub const fn with_underline_if(self, condition: bool) -> Self

Returns self with UNDERLINE inserted if condition is true.

Source

pub const fn without_underline(self) -> Self

Returns self with UNDERLINE removed.

Source

pub const fn set_underline(&mut self)

Sets UNDERLINE.

Source

pub const fn set_underline_if(&mut self, condition: bool)

Sets UNDERLINE if condition is true.

Source

pub const fn unset_underline(&mut self)

Unsets UNDERLINE.

Source

pub const fn has_dim(self) -> bool

Returns true if DIM is present.

Source

pub const fn contains_dim(self) -> bool

Returns true if all bits in DIM are present.

Source

pub const fn intersects_dim(self) -> bool

Returns true if the set shares any bit with DIM.

Source

pub const fn with_dim(self) -> Self

Returns self with DIM inserted.

Source

pub const fn with_dim_if(self, condition: bool) -> Self

Returns self with DIM inserted if condition is true.

Source

pub const fn without_dim(self) -> Self

Returns self with DIM removed.

Source

pub const fn set_dim(&mut self)

Sets DIM.

Source

pub const fn set_dim_if(&mut self, condition: bool)

Sets DIM if condition is true.

Source

pub const fn unset_dim(&mut self)

Unsets DIM.

Returns true if BLINK is present.

Returns true if all bits in BLINK are present.

Returns true if the set shares any bit with BLINK.

Returns self with BLINK inserted.

Returns self with BLINK inserted if condition is true.

Returns self with BLINK removed.

Sets BLINK.

Sets BLINK if condition is true.

Unsets BLINK.

Source

pub const fn has_inverse(self) -> bool

Returns true if INVERSE is present.

Source

pub const fn contains_inverse(self) -> bool

Returns true if all bits in INVERSE are present.

Source

pub const fn intersects_inverse(self) -> bool

Returns true if the set shares any bit with INVERSE.

Source

pub const fn with_inverse(self) -> Self

Returns self with INVERSE inserted.

Source

pub const fn with_inverse_if(self, condition: bool) -> Self

Returns self with INVERSE inserted if condition is true.

Source

pub const fn without_inverse(self) -> Self

Returns self with INVERSE removed.

Source

pub const fn set_inverse(&mut self)

Sets INVERSE.

Source

pub const fn set_inverse_if(&mut self, condition: bool)

Sets INVERSE if condition is true.

Source

pub const fn unset_inverse(&mut self)

Unsets INVERSE.

Source

pub const fn has_hidden(self) -> bool

Returns true if HIDDEN is present.

Source

pub const fn contains_hidden(self) -> bool

Returns true if all bits in HIDDEN are present.

Source

pub const fn intersects_hidden(self) -> bool

Returns true if the set shares any bit with HIDDEN.

Source

pub const fn with_hidden(self) -> Self

Returns self with HIDDEN inserted.

Source

pub const fn with_hidden_if(self, condition: bool) -> Self

Returns self with HIDDEN inserted if condition is true.

Source

pub const fn without_hidden(self) -> Self

Returns self with HIDDEN removed.

Source

pub const fn set_hidden(&mut self)

Sets HIDDEN.

Source

pub const fn set_hidden_if(&mut self, condition: bool)

Sets HIDDEN if condition is true.

Source

pub const fn unset_hidden(&mut self)

Unsets HIDDEN.

Source

pub const fn has_crossed(self) -> bool

Returns true if CROSSED is present.

Source

pub const fn contains_crossed(self) -> bool

Returns true if all bits in CROSSED are present.

Source

pub const fn intersects_crossed(self) -> bool

Returns true if the set shares any bit with CROSSED.

Source

pub const fn with_crossed(self) -> Self

Returns self with CROSSED inserted.

Source

pub const fn with_crossed_if(self, condition: bool) -> Self

Returns self with CROSSED inserted if condition is true.

Source

pub const fn without_crossed(self) -> Self

Returns self with CROSSED removed.

Source

pub const fn set_crossed(&mut self)

Sets CROSSED.

Source

pub const fn set_crossed_if(&mut self, condition: bool)

Sets CROSSED if condition is true.

Source

pub const fn unset_crossed(&mut self)

Unsets CROSSED.

Sourceยง

impl TermStyle

Common set methods

Source

pub const fn new() -> Self

Returns an empty set.

Source

pub const fn from_bits(bits: u8) -> Self

Returns a set from raw bits.

Source

pub const fn bits(self) -> u8

Returns the raw backing bits.

Source

pub const fn all() -> Self

Returns the union of all declared sets.

Source

pub const fn is_empty(self) -> bool

Returns true if no bits are set.

Source

pub const fn is_full(self) -> bool

Returns true if all the declared bits are set.

Source

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

Returns true if all bits in other are also set in self.

Source

pub const fn has(self, other: Self) -> bool

An alias of contains.

Source

pub const fn with(self, other: Self) -> Self

Returns self with other inserted.

Source

pub const fn with_if(self, condition: bool, other: Self) -> Self

Returns self with other inserted if condition is true.

Source

pub const fn without(self, other: Self) -> Self

Returns self with other removed.

Source

pub const fn toggled(self, other: Self) -> Self

Returns self with other toggled.

Sourceยง

impl TermStyle

Set operations

Source

pub const fn intersects(self, other: Self) -> bool

Returns true if self and other share any bit.

Source

pub const fn is_subset(self, other: Self) -> bool

Returns true if all bits in self are also set in other.

Source

pub const fn is_superset(self, other: Self) -> bool

Returns true if all bits in other are also set in self.

Source

pub const fn union(self, other: Self) -> Self

Returns the union of self and other.

Source

pub const fn intersection(self, other: Self) -> Self

Returns the intersection of self and other.

Source

pub const fn difference(self, other: Self) -> Self

Returns the difference of self and other.

Source

pub const fn symmetric_difference(self, other: Self) -> Self

Returns the symmetric difference of self and other.

Sourceยง

impl TermStyle

Mutating set operations

Source

pub const fn clear(&mut self)

Clears the set.

Source

pub const fn insert(&mut self, other: Self)

Inserts all bits from other.

Source

pub const fn remove(&mut self, other: Self)

Removes all bits from other.

Source

pub const fn toggle(&mut self, other: Self)

Toggles all bits from other.

Trait Implementationsยง

Sourceยง

impl Binary for TermStyle

Formats the set as a binary mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl BitAnd for TermStyle

Sourceยง

type Output = TermStyle

The resulting type after applying the & operator.
Sourceยง

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Sourceยง

impl BitAndAssign for TermStyle

Sourceยง

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Sourceยง

impl BitOr for TermStyle

Sourceยง

type Output = TermStyle

The resulting type after applying the | operator.
Sourceยง

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Sourceยง

impl BitOrAssign for TermStyle

Sourceยง

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Sourceยง

impl BitSized<{ $Set::_SET_BIT_SIZE }> for TermStyle

Sourceยง

const BIT_SIZE: usize = _

The bit size of this type (only the relevant data part, without padding). Read more
Sourceยง

const MIN_BYTE_SIZE: usize = _

The rounded up byte size for this type. Read more
Sourceยง

fn bit_size(&self) -> usize

Returns the bit size of this type (only the relevant data part, without padding). Read more
Sourceยง

fn min_byte_size(&self) -> usize

Returns the rounded up byte size for this type. Read more
Sourceยง

impl BitXor for TermStyle

Sourceยง

type Output = TermStyle

The resulting type after applying the ^ operator.
Sourceยง

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Sourceยง

impl BitXorAssign for TermStyle

Sourceยง

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Sourceยง

impl Clone for TermStyle

Sourceยง

fn clone(&self) -> TermStyle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl ConstInit for TermStyle

Sourceยง

const INIT: Self

Returns the compile-time โ€œinitial valueโ€ for a type.
Sourceยง

impl Copy for TermStyle

Sourceยง

impl Debug for TermStyle

Formats the set as a prefixed binary mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl DebugExt for TermStyle

Sourceยง

type Ctx = ReprMode

The context used to guide formatting.
Sourceยง

fn fmt_with(&self, f: &mut Formatter<'_>, ctx: &Self::Ctx) -> FmtResult<()>

Formats self under the given context.
Sourceยง

fn debug_with<'a>(&'a self, ctx: &'a Self::Ctx) -> DebugWith<'a, Self>
where Self: Sized,

Wraps self for contextual debug formatting.
Sourceยง

impl Default for TermStyle

Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Display for TermStyle

Formats the set as a prefixed binary mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Eq for TermStyle

Sourceยง

impl From<TermStyle> for TermStyleExt

Sourceยง

fn from(style: TermStyle) -> Self

Converts to this type from the input type.
Sourceยง

impl Hash for TermStyle

Sourceยง

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

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 LowerHex for TermStyle

Formats the set as a hexadecimal mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Not for TermStyle

Sourceยง

type Output = TermStyle

The resulting type after applying the ! operator.
Sourceยง

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Sourceยง

impl Octal for TermStyle

Formats the set as an octal mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Ord for TermStyle

Sourceยง

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) ยท Sourceยง

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) ยท Sourceยง

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) ยท Sourceยง

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

Restrict a value to a certain interval. Read more
Sourceยง

impl PartialEq for TermStyle

Sourceยง

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) ยท 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 TermStyle

Sourceยง

fn partial_cmp(&self, other: &Self) -> Option<Ordering> โ“˜

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) ยท 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 (const: unstable) ยท 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 (const: unstable) ยท 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 (const: unstable) ยท 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 for TermStyle

Sourceยง

type Output = TermStyle

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Sourceยง

impl SubAssign for TermStyle

Sourceยง

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Sourceยง

impl UpperHex for TermStyle

Formats the set as a hexadecimal mask over its declared bit domain.

Sourceยง

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

Formats the value using the given formatter. Read more

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> AnyExt for T
where T: Any + ?Sized,

Sourceยง

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Sourceยง

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Sourceยง

fn type_name(&self) -> &'static str โ“˜

Returns the type name of self. Read more
Sourceยง

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Sourceยง

fn type_hash(&self) -> u64

Returns a deterministic hash of the TypeId of Self.
Sourceยง

fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64

Returns a deterministic hash of the TypeId of Self using a custom hasher.
Sourceยง

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Sourceยง

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Sourceยง

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Available on crate feature alloc only.
Upcasts Box<self> as Box<dyn Any>. Read more
Sourceยง

fn downcast_ref<T: 'static>(&self) -> Option<&T> โ“˜

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some shared reference to the inner value if it is of type T. Read more
Sourceยง

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> โ“˜

Available on crate feature unsafe_layout and non-crate feature safe_code only.
Returns some exclusive reference to the inner value if it is of type T. 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> ByteSized for T

Sourceยง

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Sourceยง

const BYTE_SIZE: usize = _

The size of this type in bytes.
Sourceยง

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Sourceยง

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Sourceยง

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Sourceยง

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

Sourceยง

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

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Hook for T

Sourceยง

fn hook<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Hooks a mutation step into the value and returns it. Read more
Sourceยง

fn tap<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Taps into the value for observation and returns it unchanged. Read more
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> MemExt for T
where T: ?Sized,

Sourceยง

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Sourceยง

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Sourceยง

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Sourceยง

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Sourceยง

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Sourceยง

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Sourceยง

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Sourceยง

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Sourceยง

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Sourceยง

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Sourceยง

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Sourceยง

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Sourceยง

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Sourceยง

fn mem_as_bytes(&self) -> &[u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Sourceยง

fn mem_as_bytes_mut(&mut self) -> &mut [u8] โ“˜
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Sourceยง

impl<T, R> Morph<R> for T
where T: ?Sized,

Sourceยง

fn morph<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Morphs the value into a new one and returns it. Read more
Sourceยง

fn morph_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Morphs the value by shared reference and returns the result. Read more
Sourceยง

fn morph_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Morphs the value by exclusive reference and returns the result. Read more
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> ToString for T
where T: Display + ?Sized,

Sourceยง

fn to_string(&self) -> String โ“˜

Converts the given value to a String. 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.