pub struct Attribute { /* private fields */ }
Expand description
Discriminating enum for Color
attributes.
git-config
supports modifiers and their negators. The negating color
attributes are equivalent to having a no
or no-
prefix to the normal
variant.
Implementations
sourceimpl Attribute
impl Attribute
pub const BOLD: Attribute = Self{ bits: 1 << 1,}
pub const DIM: Attribute = Self{ bits: 1 << 2,}
pub const ITALIC: Attribute = Self{ bits: 1 << 3,}
pub const UL: Attribute = Self{ bits: 1 << 4,}
pub const BLINK: Attribute = Self{ bits: 1 << 5,}
pub const REVERSE: Attribute = Self{ bits: 1 << 6,}
pub const STRIKE: Attribute = Self{ bits: 1 << 7,}
sourcepub const RESET: Attribute = Self{ bits: 1 << 8,}
pub const RESET: Attribute = Self{ bits: 1 << 8,}
Reset is special as we have to be able to parse it, without git actually doing anything with it
pub const NO_DIM: Attribute = Self{ bits: 1 << 21,}
pub const NO_BOLD: Attribute = Self{ bits: 1 << 22,}
pub const NO_ITALIC: Attribute = Self{ bits: 1 << 23,}
pub const NO_UL: Attribute = Self{ bits: 1 << 24,}
pub const NO_BLINK: Attribute = Self{ bits: 1 << 25,}
pub const NO_REVERSE: Attribute = Self{ bits: 1 << 26,}
pub const NO_STRIKE: Attribute = Self{ bits: 1 << 27,}
sourcepub const fn from_bits(bits: u32) -> Option<Attribute>
pub const fn from_bits(bits: u32) -> Option<Attribute>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
sourcepub const fn from_bits_truncate(bits: u32) -> Attribute
pub const fn from_bits_truncate(bits: u32) -> Attribute
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
sourcepub const unsafe fn from_bits_unchecked(bits: u32) -> Attribute
pub const unsafe fn from_bits_unchecked(bits: u32) -> Attribute
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Safety
The caller of the bitflags!
macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked()
has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
sourcepub const fn intersects(&self, other: Attribute) -> bool
pub const fn intersects(&self, other: Attribute) -> bool
Returns true
if there are flags common to both self
and other
.
sourcepub const fn contains(&self, other: Attribute) -> bool
pub const fn contains(&self, other: Attribute) -> bool
Returns true
if all of the flags in other
are contained within self
.
sourcepub fn set(&mut self, other: Attribute, value: bool)
pub fn set(&mut self, other: Attribute, value: bool)
Inserts or removes the specified flags depending on the passed value.
sourcepub const fn intersection(self, other: Attribute) -> Attribute
pub const fn intersection(self, other: Attribute) -> Attribute
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
sourcepub const fn union(self, other: Attribute) -> Attribute
pub const fn union(self, other: Attribute) -> Attribute
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
sourcepub const fn difference(self, other: Attribute) -> Attribute
pub const fn difference(self, other: Attribute) -> Attribute
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
sourcepub const fn symmetric_difference(self, other: Attribute) -> Attribute
pub const fn symmetric_difference(self, other: Attribute) -> Attribute
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
sourcepub const fn complement(self) -> Attribute
pub const fn complement(self) -> Attribute
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
Trait Implementations
sourceimpl BitAndAssign<Attribute> for Attribute
impl BitAndAssign<Attribute> for Attribute
sourcefn bitand_assign(&mut self, other: Attribute)
fn bitand_assign(&mut self, other: Attribute)
Disables all flags disabled in the set.
sourceimpl BitOrAssign<Attribute> for Attribute
impl BitOrAssign<Attribute> for Attribute
sourcefn bitor_assign(&mut self, other: Attribute)
fn bitor_assign(&mut self, other: Attribute)
Adds the set of flags.
sourceimpl BitXorAssign<Attribute> for Attribute
impl BitXorAssign<Attribute> for Attribute
sourcefn bitxor_assign(&mut self, other: Attribute)
fn bitxor_assign(&mut self, other: Attribute)
Toggles the set of flags.
sourceimpl Extend<Attribute> for Attribute
impl Extend<Attribute> for Attribute
sourcefn extend<T>(&mut self, iterator: T) where
T: IntoIterator<Item = Attribute>,
fn extend<T>(&mut self, iterator: T) where
T: IntoIterator<Item = Attribute>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<Attribute> for Attribute
impl FromIterator<Attribute> for Attribute
sourceimpl Ord for Attribute
impl Ord for Attribute
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Attribute> for Attribute
impl PartialEq<Attribute> for Attribute
sourceimpl PartialOrd<Attribute> for Attribute
impl PartialOrd<Attribute> for Attribute
sourcefn partial_cmp(&self, other: &Attribute) -> Option<Ordering>
fn partial_cmp(&self, other: &Attribute) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<Attribute> for Attribute
impl SubAssign<Attribute> for Attribute
sourcefn sub_assign(&mut self, other: Attribute)
fn sub_assign(&mut self, other: Attribute)
Disables all flags enabled in the set.
impl Copy for Attribute
impl Eq for Attribute
impl StructuralEq for Attribute
impl StructuralPartialEq for Attribute
Auto Trait Implementations
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnwindSafe for Attribute
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> ToCompactString for T where
T: Display,
impl<T> ToCompactString for T where
T: Display,
fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [CompactString
]. Read more