ArgValue

Enum ArgValue 

Source
pub enum ArgValue {
    Literal(Lit),
    Type(Type),
    Expr(Expr),
    None,
}
Expand description

Value for attribute or attribute argument, i.e. for #[attr = value] and #[attr(arg = value)] this is the value part of the attribute. Can be either a single literal or a single valid rust type name

Variants§

§

Literal(Lit)

Attribute value represented by a literal

§

Type(Type)

Attribute value represented by a type name

§

Expr(Expr)

Attribute value represented by an expression

§

None

No value is given

Implementations§

Source§

impl ArgValue

Source

pub fn into_literal_value(self) -> Result<Lit, Error>

Converts into literal value for ArgValue::Literal variant or fails with Error::ArgValueMustBeLiteral otherwise

Source

pub fn into_type_value(self) -> Result<Type, Error>

Converts into type value for ArgValue::Type variant or fails with Error::ArgValueMustBeType otherwise

Source

pub fn into_type_expr(self) -> Result<Expr, Error>

Converts into type value for ArgValue::Expr variant or fails with Error::ArgValueMustBeExpr otherwise

Source

pub fn to_literal_value(&self) -> Result<Lit, Error>

Constructs literal value for ArgValue::Literal variant or fails with Error::ArgValueMustBeLiteral otherwise

Source

pub fn to_type_value(&self) -> Result<Type, Error>

Constructs type value for ArgValue::Type variant or fails with Error::ArgValueMustBeType otherwise

Source

pub fn to_type_expr(&self) -> Result<Expr, Error>

Constructs type value for ArgValue::Expr variant or fails with Error::ArgValueMustBeExpr otherwise

Source

pub fn as_literal_value(&self) -> Option<&Lit>

Returns a reference to a literal value for ArgValue::Literal variant, or None otherwise.

Source

pub fn as_type_value(&self) -> Option<&Type>

Returns a reference to a literal value for ArgValue::Type variant, or None otherwise.

Source

pub fn as_type_expr(&self) -> Option<&Expr>

Returns a reference to a literal value for ArgValue::Expr variant, or None otherwise.

Source

pub fn is_none(&self) -> bool

Tests whether the self is set to ArgValue::None

Source

pub fn is_some(&self) -> bool

Tests whether the self is not set to ArgValue::None

Source

pub fn value_class(&self) -> Option<ValueClass>

Returns ValueClass for the current value, if any

Trait Implementations§

Source§

impl Clone for ArgValue

Source§

fn clone(&self) -> ArgValue

Returns a duplicate 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 ArgValue

Source§

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

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

impl From<&[u8]> for ArgValue

Source§

fn from(val: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for ArgValue

Source§

fn from(val: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Ident> for ArgValue

Source§

fn from(ident: Ident) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitBool>> for ArgValue

Source§

fn from(val: Option<LitBool>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitByteStr>> for ArgValue

Source§

fn from(val: Option<LitByteStr>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitChar>> for ArgValue

Source§

fn from(val: Option<LitChar>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitFloat>> for ArgValue

Source§

fn from(val: Option<LitFloat>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitInt>> for ArgValue

Source§

fn from(val: Option<LitInt>) -> Self

Converts to this type from the input type.
Source§

impl From<Option<LitStr>> for ArgValue

Source§

fn from(val: Option<LitStr>) -> Self

Converts to this type from the input type.
Source§

impl From<Path> for ArgValue

Source§

fn from(path: Path) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ArgValue

Source§

fn from(val: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for ArgValue

Source§

fn from(val: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for ArgValue

Source§

fn from(val: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for ArgValue

Source§

fn from(val: char) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for ArgValue

Source§

fn from(val: f64) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for ArgValue

Source§

fn from(val: isize) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for ArgValue

Source§

fn from(val: usize) -> Self

Converts to this type from the input type.
Source§

impl Parse for ArgValue

Source§

fn parse(input: &ParseBuffer<'_>) -> Result<Self>

Source§

impl ToTokens for ArgValue

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) -> TokenStream
where Self: Sized,

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

impl TryFrom<ArgValue> for Expr

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Ident

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitBool

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitByteStr

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitChar

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitFloat

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitInt

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for LitStr

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<Expr>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<Ident>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitBool>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitByteStr>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitChar>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitFloat>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitInt>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<LitStr>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Option<Path>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Path

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for String

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for Vec<u8>

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for bool

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ArgValue> for char

Source§

type Error = Error

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

fn try_from(value: ArgValue) -> Result<Self, Self::Error>

Performs the conversion.

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> Spanned for T
where 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 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 = 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 264 bytes

Size for each variant:

  • Literal: 32 bytes
  • Type: 264 bytes
  • Expr: 256 bytes
  • None: 0 bytes