Struct deluxe_core::Flag

source ·
pub struct Flag(_);
Expand description

A value for a boolean named field that can only be a name (set) or omitted (unset).

Similar to an Option<SpannedValue<bool>> but does not allow = or () after the field name. Thus, it is only useful with named fields. Parsing this out of a tuple struct or tuple variant will always result in a parse error.

It is not necessary to use #[deluxe(default)] on a field using this type. The field will automatically be created with a false value if the name is omitted.

Implementations§

source§

impl Flag

source

pub fn set(span: Span) -> Self

Creates a new true flag value spanned to span.

source

pub fn set_call_site() -> Self

Creates a new true flag value spanned to Span::call_site.

source

pub fn unset() -> Self

Creates a new false flag value.

source

pub fn is_set(&self) -> bool

Returns true if the flag was set.

Trait Implementations§

source§

impl Clone for Flag

source§

fn clone(&self) -> Flag

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 Flag

source§

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

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

impl Default for Flag

source§

fn default() -> Flag

Returns the “default value” for a type. Read more
source§

impl From<Flag> for bool

source§

fn from(value: Flag) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Flag

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl ParseMetaItem for Flag

source§

fn parse_meta_item(input: ParseStream<'_>, mode: ParseMode) -> Result<Self>

Parse the item from the tokens in input. Read more
source§

fn parse_meta_item_inline<'s, S: Borrow<ParseBuffer<'s>>>( inputs: &[S], _mode: ParseMode ) -> Result<Self>

Parse the item in an inline context. Read more
source§

fn parse_meta_item_flag(span: Span) -> Result<Self>

Parses an empty flag value. Read more
source§

fn parse_meta_item_named( input: ParseStream<'_>, _name: &str, span: Span ) -> Result<Self>

Parses the item following a name. Read more
source§

fn missing_meta_item(_name: &str, _span: Span) -> Result<Self>

Fallback for when a required item is missing. Read more
source§

impl PartialEq<Flag> for Flag

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Flag> for bool

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<bool> for Flag

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToTokens for Flag

source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStreamwhere Self: Sized,

Convert self directly into a TokenStream object. Read more
source§

impl Copy for Flag

source§

impl Eq for Flag

Auto Trait Implementations§

§

impl RefUnwindSafe for Flag

§

impl !Send for Flag

§

impl !Sync for Flag

§

impl Unpin for Flag

§

impl UnwindSafe for Flag

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> Spanned for Twhere T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.