Enum amplify_syn::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
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 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> 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.