pub struct AttributeSet(/* private fields */);Expand description
A set of Attribute values.
AttributeSet values can be combined with bitwise operators and can be
iterated over.
Implementations§
Source§impl AttributeSet
impl AttributeSet
Sourcepub const EMPTY: AttributeSet
pub const EMPTY: AttributeSet
A set containing no Attributes
Sourcepub const ALL: AttributeSet
pub const ALL: AttributeSet
A set containing all Attributes
Sourcepub fn new() -> AttributeSet
pub fn new() -> AttributeSet
Return a new set containing no Attributes
Sourcepub fn contains(self, attr: Attribute) -> bool
pub fn contains(self, attr: Attribute) -> bool
Test whether the set contains the given Attribute
Sourcepub fn insert(&mut self, attr: Attribute) -> bool
pub fn insert(&mut self, attr: Attribute) -> bool
Adds the given Attribute to the set if not already present.
Returns true if the given Attribute was not already in the set.
§Example
use parse_style::{Attribute, AttributeSet};
let mut attrset = AttributeSet::new();
assert!(!attrset.contains(Attribute::Bold));
assert!(attrset.insert(Attribute::Bold));
assert!(attrset.contains(Attribute::Bold));
assert!(!attrset.insert(Attribute::Bold));
assert!(attrset.contains(Attribute::Bold));Sourcepub fn remove(&mut self, attr: Attribute) -> bool
pub fn remove(&mut self, attr: Attribute) -> bool
Removes the given Attribute from the set if present.
Returns true if the given Attribute was present in the set.
§Example
use parse_style::{Attribute, AttributeSet};
let mut attrset = AttributeSet::from([Attribute::Bold]);
assert!(attrset.contains(Attribute::Bold));
assert!(attrset.remove(Attribute::Bold));
assert!(!attrset.contains(Attribute::Bold));
assert!(!attrset.remove(Attribute::Bold));
assert!(!attrset.contains(Attribute::Bold));Sourcepub fn is_disjoint(self, other: AttributeSet) -> bool
pub fn is_disjoint(self, other: AttributeSet) -> bool
Returns true if self and other are disjoint, i.e., if there is no
Attribute that is in both sets.
§Examples
use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold,
Attribute::Italic]);
let attrset2 = AttributeSet::from([Attribute::Underline,
Attribute::Blink]);
assert!(attrset1.is_disjoint(attrset2));
assert!(attrset2.is_disjoint(attrset1));use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold,
Attribute::Italic]);
let attrset2 = AttributeSet::from([Attribute::Bold,
Attribute::Underline]);
assert!(!attrset1.is_disjoint(attrset2));
assert!(!attrset2.is_disjoint(attrset1));Sourcepub fn is_subset(self, other: AttributeSet) -> bool
pub fn is_subset(self, other: AttributeSet) -> bool
Returns true if self is a subset of other
§Examples
use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold]);
let attrset2 = AttributeSet::from([Attribute::Bold,
Attribute::Underline]);
assert!(attrset1.is_subset(attrset2));
assert!(!attrset2.is_subset(attrset1));use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold,
Attribute::Italic]);
let attrset2 = AttributeSet::from([Attribute::Bold,
Attribute::Underline]);
assert!(!attrset1.is_subset(attrset2));
assert!(!attrset2.is_subset(attrset1));Sourcepub fn is_superset(self, other: AttributeSet) -> bool
pub fn is_superset(self, other: AttributeSet) -> bool
Returns true if self is a superset of other
§Examples
use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold]);
let attrset2 = AttributeSet::from([Attribute::Bold,
Attribute::Underline]);
assert!(!attrset1.is_superset(attrset2));
assert!(attrset2.is_superset(attrset1));use parse_style::{Attribute, AttributeSet};
let attrset1 = AttributeSet::from([Attribute::Bold,
Attribute::Italic]);
let attrset2 = AttributeSet::from([Attribute::Bold,
Attribute::Underline]);
assert!(!attrset1.is_superset(attrset2));
assert!(!attrset2.is_superset(attrset1));Trait Implementations§
Source§impl<A: Into<AttributeSet>> BitAnd<A> for AttributeSet
impl<A: Into<AttributeSet>> BitAnd<A> for AttributeSet
Source§type Output = AttributeSet
type Output = AttributeSet
& operator.Source§fn bitand(self, rhs: A) -> AttributeSet
fn bitand(self, rhs: A) -> AttributeSet
& operation. Read moreSource§impl<A: Into<AttributeSet>> BitAndAssign<A> for AttributeSet
impl<A: Into<AttributeSet>> BitAndAssign<A> for AttributeSet
Source§fn bitand_assign(&mut self, rhs: A)
fn bitand_assign(&mut self, rhs: A)
&= operation. Read moreSource§impl<A: Into<AttributeSet>> BitOr<A> for AttributeSet
impl<A: Into<AttributeSet>> BitOr<A> for AttributeSet
Source§type Output = AttributeSet
type Output = AttributeSet
| operator.Source§fn bitor(self, rhs: A) -> AttributeSet
fn bitor(self, rhs: A) -> AttributeSet
| operation. Read moreSource§impl<A: Into<AttributeSet>> BitOrAssign<A> for AttributeSet
impl<A: Into<AttributeSet>> BitOrAssign<A> for AttributeSet
Source§fn bitor_assign(&mut self, rhs: A)
fn bitor_assign(&mut self, rhs: A)
|= operation. Read moreSource§impl<A: Into<AttributeSet>> BitXor<A> for AttributeSet
impl<A: Into<AttributeSet>> BitXor<A> for AttributeSet
Source§type Output = AttributeSet
type Output = AttributeSet
^ operator.Source§fn bitxor(self, rhs: A) -> AttributeSet
fn bitxor(self, rhs: A) -> AttributeSet
^ operation. Read moreSource§impl<A: Into<AttributeSet>> BitXorAssign<A> for AttributeSet
impl<A: Into<AttributeSet>> BitXorAssign<A> for AttributeSet
Source§fn bitxor_assign(&mut self, rhs: A)
fn bitxor_assign(&mut self, rhs: A)
^= operation. Read moreSource§impl Clone for AttributeSet
impl Clone for AttributeSet
Source§fn clone(&self) -> AttributeSet
fn clone(&self) -> AttributeSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for AttributeSet
Source§impl Debug for AttributeSet
impl Debug for AttributeSet
Source§impl Default for AttributeSet
impl Default for AttributeSet
Source§fn default() -> AttributeSet
fn default() -> AttributeSet
impl Eq for AttributeSet
Source§impl Extend<Attribute> for AttributeSet
impl Extend<Attribute> for AttributeSet
Source§fn extend<I: IntoIterator<Item = Attribute>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Attribute>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<Attribute> for AttributeSet
impl From<Attribute> for AttributeSet
Source§fn from(value: Attribute) -> AttributeSet
fn from(value: Attribute) -> AttributeSet
Source§impl From<AttributeSet> for Effects
Available on crate feature anstyle only.
impl From<AttributeSet> for Effects
anstyle only.Source§fn from(value: AttributeSet) -> Effects
fn from(value: AttributeSet) -> Effects
Convert an AttributeSet to an anstyle::Effects
§Data Loss
The following attributes are discarded during conversion, as they have
no anstyle::Effects equivalents:
Source§impl From<AttributeSet> for Attributes
Available on crate feature crossterm only.
impl From<AttributeSet> for Attributes
crossterm only.Source§fn from(value: AttributeSet) -> Attributes
fn from(value: AttributeSet) -> Attributes
Convert an AttributeSet to a crossterm::style::Attributes that
enables the input attributes
Source§impl From<AttributeSet> for Modifier
Available on crate feature ratatui only.
impl From<AttributeSet> for Modifier
ratatui only.Source§fn from(value: AttributeSet) -> Modifier
fn from(value: AttributeSet) -> Modifier
Convert an AttributeSet to a ratatui_core::style::Modifier
§Data Loss
The following attributes are discarded during conversion, as they have
no ratatui_core::style::Modifier equivalents:
Source§impl From<AttributeSet> for Style
impl From<AttributeSet> for Style
Source§fn from(value: AttributeSet) -> Style
fn from(value: AttributeSet) -> Style
Construct a new Style that enables the given attributes
Source§impl From<Effects> for AttributeSet
Available on crate feature anstyle only.
impl From<Effects> for AttributeSet
anstyle only.Source§fn from(value: Effects) -> AttributeSet
fn from(value: Effects) -> AttributeSet
Convert an anstyle::Effects to an AttributeSet
§Data Loss
The following effects are discarded during conversion, as they have no
Attribute equivalents:
Source§impl From<Modifier> for AttributeSet
Available on crate feature ratatui only.
impl From<Modifier> for AttributeSet
ratatui only.Source§fn from(value: Modifier) -> AttributeSet
fn from(value: Modifier) -> AttributeSet
Convert a ratatui_core::style::Modifier to an AttributeSet
Source§impl FromIterator<Attribute> for AttributeSet
impl FromIterator<Attribute> for AttributeSet
Source§impl Hash for AttributeSet
impl Hash for AttributeSet
Source§impl IntoIterator for AttributeSet
impl IntoIterator for AttributeSet
Source§impl Not for AttributeSet
impl Not for AttributeSet
Source§type Output = AttributeSet
type Output = AttributeSet
! operator.Source§fn not(self) -> AttributeSet
fn not(self) -> AttributeSet
! operation. Read moreSource§impl Ord for AttributeSet
impl Ord for AttributeSet
Source§fn cmp(&self, other: &AttributeSet) -> Ordering
fn cmp(&self, other: &AttributeSet) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for AttributeSet
impl PartialEq for AttributeSet
Source§fn eq(&self, other: &AttributeSet) -> bool
fn eq(&self, other: &AttributeSet) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for AttributeSet
impl PartialOrd for AttributeSet
impl StructuralPartialEq for AttributeSet
Source§impl<A: Into<AttributeSet>> Sub<A> for AttributeSet
impl<A: Into<AttributeSet>> Sub<A> for AttributeSet
Source§type Output = AttributeSet
type Output = AttributeSet
- operator.Source§fn sub(self, rhs: A) -> AttributeSet
fn sub(self, rhs: A) -> AttributeSet
- operation. Read moreSource§impl<A: Into<AttributeSet>> SubAssign<A> for AttributeSet
impl<A: Into<AttributeSet>> SubAssign<A> for AttributeSet
Source§fn sub_assign(&mut self, rhs: A)
fn sub_assign(&mut self, rhs: A)
-= operation. Read moreAuto Trait Implementations§
impl Freeze for AttributeSet
impl RefUnwindSafe for AttributeSet
impl Send for AttributeSet
impl Sync for AttributeSet
impl Unpin for AttributeSet
impl UnsafeUnpin for AttributeSet
impl UnwindSafe for AttributeSet
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more