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 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 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, Global>> 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) -> TokenStreamwhere Self: Sized,

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

impl TryFrom<ArgValue> for Expr

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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>

§

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>

§

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>

§

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>

§

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>

§

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>

§

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>

§

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>

§

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>

§

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

§

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

§

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>

§

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

§

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

§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 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.
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.
source§

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

Performs the conversion.