bitflag_attr::example_generated

Struct Flags

Source
pub struct Flags(/* private fields */)
where
    u32: BitflagPrimitive;
Expand description

Example of the generated code by bitflag macro.

Implementations§

Source§

impl Flags

Source

pub const A: Self

The value A, at bit position 0.

Source

pub const B: Self

The value B, at bit position 1.

Source

pub const C: Self

The value C, at bit position 2.

Source

pub const ABC: Self

The combination of A, B, and C.

Source

pub const fn bits(&self) -> u32

Return the underlying bits of the bitflag

Source

pub const fn from_bits(bits: u32) -> Option<Self>

Converts from a bits value. Returning None is any unknown bits are set.

Source

pub const fn from_bits_truncate(bits: u32) -> Self

Convert from bits value, unsetting any unknown bits.

Source

pub const fn from_bits_retain(bits: u32) -> Self

Convert from bits value exactly.

Source

pub fn from_flag_name(name: &str) -> Option<Self>

Convert from a flag name.

Source

pub const fn empty() -> Self

Construct an empty bitflag.

Source

pub const fn is_empty(&self) -> bool

Returns true if the flag is empty.

Source

pub const fn all_bits() -> Self

Returns a bitflag that contains all value.

This will include bits that do not have any flags/meaning. Use all if you want only the specified flags set.

Source

pub const fn is_all_bits(&self) -> bool

Returns true if the bitflag contains all value bits set.

This will check for all bits. Use is_all if you want to check for all specified flags.

Source

pub const fn all() -> Self

Construct a bitflag with all known flags set.

This will only set the flags specified as associated constant.

Source

pub const fn is_all(&self) -> bool

Returns true if the bitflag contais all known flags.

Source

pub const fn truncate(&self) -> Self

Returns a bit flag that only has bits corresponding to the specified flags as associated constant.

Source

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

Returns true if this bitflag intersects with any value in other.

This is equivalent to (self & other) != Self::empty()

Source

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

Returns true if this bitflag contains all values of other.

This is equivalent to (self & other) == other

Source

pub const fn not(self) -> Self

Returns the bitwise NOT of the flag.

This function does not truncate unused bits (bits that do not have any flags/meaning). Use complement if you want that the result to be truncated in one call.

Source

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

Returns the bitwise AND of the flag.

Source

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

Returns the bitwise OR of the flag with other.

Source

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

Returns the bitwise XOR of the flag with other.

Source

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

Returns the intersection from this value with other.

Source

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

Returns the union from this value with other

Source

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

Returns the difference from this value with other.

In other words, returns the intersection of this value with the negation of other.

Source

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

Returns the symmetric difference from this value with other.

Source

pub const fn complement(self) -> Self

Returns the complement of the value.

This is very similar to the not, but truncates non used bits

Source

pub fn set(&mut self, other: Self)

Set the flags in other in the value.

Source

pub fn unset(&mut self, other: Self)

Unset the flags in other in the value.

Source

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

Toggle the flags in other in the value.

Source§

impl Flags

Source

pub const fn iter(&self) -> FlagsIter

Yield a set of contained flags values.

Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.

Source

pub const fn iter_names(&self) -> FlagsIterNames

Yield a set of contained named flags values.

This method is like iter, except only yields bits in contained named flags. Any unknown bits, or bits not corresponding to a contained flag will not be yielded.

Trait Implementations§

Source§

impl Binary for Flags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl BitAnd for Flags

Source§

type Output = Flags

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign for Flags

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for Flags

Source§

type Output = Flags

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign for Flags

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for Flags

Source§

type Output = Flags

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Flags

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for Flags

Source§

fn clone(&self) -> Flags

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Flags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Extend<Flags> for Flags

Source§

fn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T)

Set all flags of iter to self

Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<Flags> for u32

Source§

fn from(val: Flags) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Flags

Source§

fn from(val: u32) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Flags> for Flags

Source§

fn from_iter<T: IntoIterator<Item = Self>>(iter: T) -> Self

Create a #ty_name from a iterator of flags.

Source§

impl Hash for Flags

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 IntoIterator for &Flags

Source§

type Item = Flags

The type of the elements being iterated over.
Source§

type IntoIter = FlagsIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Flags

Source§

type Item = Flags

The type of the elements being iterated over.
Source§

type IntoIter = FlagsIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl LowerHex for Flags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Not for Flags

Source§

type Output = Flags

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Octal for Flags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Ord for Flags

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · 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 Flags

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Flags

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Flags

Source§

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

The intersection of a source flag with the complement of a target flags value

Source§

type Output = Flags

The resulting type after applying the - operator.
Source§

impl SubAssign for Flags

Source§

fn sub_assign(&mut self, rhs: Self)

The intersection of a source flag with the complement of a target flags value

Source§

impl UpperHex for Flags

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for Flags

Source§

impl Eq for Flags

Source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnwindSafe for Flags

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> 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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.