bitflag_attr::example_generated

Struct SimpleFlag

Source
pub struct SimpleFlag(/* private fields */);
Expand description

A simple bitflag

Implementations§

Source§

impl SimpleFlag

Source

pub const Flag1: Self

Source

pub const Flag2: Self

Source

pub const Flag3: Self

Source

pub const Flag4: Self

Source

pub const Flag5: Self

Source

pub const Flag6: Self

Source

pub const Flag7: Self

Source

pub const Flag8: Self

Source

pub const Flag9: Self

Source§

impl SimpleFlag

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 SimpleFlag

Source

pub const fn iter(&self) -> SimpleFlagIter

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) -> SimpleFlagIterNames

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 SimpleFlag

Source§

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

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

impl BitAnd for SimpleFlag

Source§

type Output = SimpleFlag

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign for SimpleFlag

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for SimpleFlag

Source§

type Output = SimpleFlag

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign for SimpleFlag

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for SimpleFlag

Source§

type Output = SimpleFlag

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign for SimpleFlag

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for SimpleFlag

Source§

fn clone(&self) -> SimpleFlag

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 SimpleFlag

Source§

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

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

impl Extend<SimpleFlag> for SimpleFlag

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<SimpleFlag> for u32

Source§

fn from(val: SimpleFlag) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for SimpleFlag

Source§

fn from(val: u32) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<SimpleFlag> for SimpleFlag

Source§

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

Create a #ty_name from a iterator of flags.

Source§

impl Hash for SimpleFlag

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 &SimpleFlag

Source§

type Item = SimpleFlag

The type of the elements being iterated over.
Source§

type IntoIter = SimpleFlagIter

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 SimpleFlag

Source§

type Item = SimpleFlag

The type of the elements being iterated over.
Source§

type IntoIter = SimpleFlagIter

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 SimpleFlag

Source§

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

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

impl Not for SimpleFlag

Source§

type Output = SimpleFlag

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Octal for SimpleFlag

Source§

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

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

impl Ord for SimpleFlag

Source§

fn cmp(&self, other: &SimpleFlag) -> 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 SimpleFlag

Source§

fn eq(&self, other: &SimpleFlag) -> 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 SimpleFlag

Source§

fn partial_cmp(&self, other: &SimpleFlag) -> 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 SimpleFlag

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 = SimpleFlag

The resulting type after applying the - operator.
Source§

impl SubAssign for SimpleFlag

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 SimpleFlag

Source§

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

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

impl Copy for SimpleFlag

Source§

impl Eq for SimpleFlag

Source§

impl StructuralPartialEq for SimpleFlag

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