Skip to main content

FlagBit

Struct FlagBit 

Source
pub struct FlagBit {
    pub ident: Ident,
    pub rename: Option<String>,
    pub upstream: Option<Ident>,
    pub value: u128,
    pub attrs: Vec<Attribute>,
}
Expand description

One declared bit.

Fields§

§ident: Ident

The bit as the MANIFEST spells it — the enum variant’s own identifier.

§rename: Option<String>

rename = "…" in the DECLARED mode, which moves the word every face spells this bit with.

A mirror’s rename fills upstream instead, the two knobs being one word reading two ways: see that field for why a restatement has no word of its own to move.

§upstream: Option<Ident>

rename = "…" in the MIRROR mode — the upstream const this bit restates.

A mirror’s words are its OWN, where a mirrored vocabulary’s are the upstream’s, and the asymmetry is the arity again: a flags set stores a bit PATTERN, so the mirrored type’s text form is read off this crate’s bit table and never off the upstream’s. What a restatement can get wrong is therefore not a word but a NUMBER, and the upstream const is what the drift pin compares against.

§value: u128

The bit’s value, evaluated.

§attrs: Vec<Attribute>

The declaration’s own non-ingraph attributes, forwarded onto the emitted const in order — which is what carries a bit’s doc comment into the expansion.

Implementations§

Source§

impl FlagBit

Source

pub fn word(&self) -> String

The WORD this bit is spelled with: its rename, else its identifier SHOUTED.

One string serving three seats — the emitted const’s name, the strict text form’s token, and the wire’s name-list entry — which is what keeps bitflags::parser::to_writer usable as the text renderer instead of a second one written here.

The shout is a Rust CONVENTION rather than a stored-word decision, which is why this kind cases where a vocabulary’s stored word is verbatim: an associated const is SCREAMING_SNAKE_CASE everywhere in the ecosystem, and a flags column stores no word at all for a casing rule to rewrite.

Source

pub fn field(&self) -> String

The wire FIELD this bit takes — its word, under GraphQL’s own casing.

Derived from word rather than from the identifier, so a rename moves both and they stay two readings of one declaration.

Source

pub fn constant(&self) -> Ident

The const’s name in the expansion — word as an identifier.

Source

pub fn upstream(&self) -> Ident

The UPSTREAM const a mirror’s bit restates — the declared rename, else this bit’s own constant.

The drift pin is written from this, so a name that answers to nothing upstream is E0599 at the token that named it. That is the whole enforcement and it is the compiler’s: this side cannot see the upstream declaration, and a table of upstream names kept here would be a second copy of somebody else’s bitflags!.

Trait Implementations§

Source§

impl Clone for FlagBit

Source§

fn clone(&self) -> Self

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 Debug for FlagBit

Source§

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

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> 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.