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
impl ArgValue
Sourcepub fn into_literal_value(self) -> Result<Lit, Error>
pub fn into_literal_value(self) -> Result<Lit, Error>
Converts into literal value for ArgValue::Literal
variant or fails
with Error::ArgValueMustBeLiteral
otherwise
Sourcepub fn into_type_value(self) -> Result<Type, Error>
pub fn into_type_value(self) -> Result<Type, Error>
Converts into type value for ArgValue::Type
variant or fails with
Error::ArgValueMustBeType
otherwise
Sourcepub fn into_type_expr(self) -> Result<Expr, Error>
pub fn into_type_expr(self) -> Result<Expr, Error>
Converts into type value for ArgValue::Expr
variant or fails with
Error::ArgValueMustBeExpr
otherwise
Sourcepub fn to_literal_value(&self) -> Result<Lit, Error>
pub fn to_literal_value(&self) -> Result<Lit, Error>
Constructs literal value for ArgValue::Literal
variant or fails with
Error::ArgValueMustBeLiteral
otherwise
Sourcepub fn to_type_value(&self) -> Result<Type, Error>
pub fn to_type_value(&self) -> Result<Type, Error>
Constructs type value for ArgValue::Type
variant or fails with
Error::ArgValueMustBeType
otherwise
Sourcepub fn to_type_expr(&self) -> Result<Expr, Error>
pub fn to_type_expr(&self) -> Result<Expr, Error>
Constructs type value for ArgValue::Expr
variant or fails with
Error::ArgValueMustBeExpr
otherwise
Sourcepub fn as_literal_value(&self) -> Option<&Lit>
pub fn as_literal_value(&self) -> Option<&Lit>
Returns a reference to a literal value for ArgValue::Literal
variant, or None
otherwise.
Sourcepub fn as_type_value(&self) -> Option<&Type>
pub fn as_type_value(&self) -> Option<&Type>
Returns a reference to a literal value for ArgValue::Type
variant, or None
otherwise.
Sourcepub fn as_type_expr(&self) -> Option<&Expr>
pub fn as_type_expr(&self) -> Option<&Expr>
Returns a reference to a literal value for ArgValue::Expr
variant, or None
otherwise.
Sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Tests whether the self is set to ArgValue::None
Sourcepub fn is_some(&self) -> bool
pub fn is_some(&self) -> bool
Tests whether the self is not set to ArgValue::None
Sourcepub fn value_class(&self) -> Option<ValueClass>
pub fn value_class(&self) -> Option<ValueClass>
Returns ValueClass
for the current value, if any
Trait Implementations§
Source§impl From<Option<LitByteStr>> for ArgValue
impl From<Option<LitByteStr>> for ArgValue
Source§fn from(val: Option<LitByteStr>) -> Self
fn from(val: Option<LitByteStr>) -> Self
Source§impl ToTokens for ArgValue
impl ToTokens for ArgValue
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Source§impl TryFrom<ArgValue> for LitByteStr
impl TryFrom<ArgValue> for LitByteStr
Auto Trait Implementations§
impl Freeze for ArgValue
impl RefUnwindSafe for ArgValue
impl !Send for ArgValue
impl !Sync for ArgValue
impl Unpin for ArgValue
impl UnwindSafe for ArgValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.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 bytesType
: 264 bytesExpr
: 256 bytesNone
: 0 bytes