pub enum Meta {
PathValue(PathValue),
PathList(PathList),
Expr(Expr),
Verbatim(TokenStream),
}Variants§
PathValue(PathValue)
A path followed by an equal sign and a single Meta — e.g. my_attribute = my_value.
PathList(PathList)
A path followed by a wrapped list of Metas — e.g. my_attribute(one, two, three).
This accepts an optional equal sign before the list — e.g. my_attribute = (one, two, three).
Expr(Expr)
An expression — e.g. my_attribute, 42, "hello" or a + b.
Verbatim(TokenStream)
A verbatim token stream — e.g. [<=>].
This is the fallback for any other Meta that does not match the other variants.
Implementations§
Source§impl Meta
impl Meta
pub fn path(&self) -> Result<&Path>
Sourcepub fn path_str(&self) -> String
pub fn path_str(&self) -> String
Returns the path as a string if it is a valid path or an empty string if it is not a path.
pub fn is_path_or_list(&self) -> bool
pub fn is_path_or_empty_list(&self) -> bool
pub fn as_path(&self) -> Result<&Path>
pub fn as_path_list(&self) -> Result<&PathList>
pub fn as_path_value(&self) -> Result<&PathValue>
pub fn as_value(&self) -> Result<&Meta>
pub fn as_expr_or_value_expr(&self) -> Result<&Expr>
pub fn as_expr(&self) -> Result<&Expr>
pub fn as_verbatim(&self, msg: impl Display) -> Result<&TokenStream>
pub fn assert_directive(&self, directive: &str) -> Result<&Self>
Trait Implementations§
Source§impl From<TokenStream> for Meta
impl From<TokenStream> for Meta
Source§fn from(value: TokenStream) -> Self
fn from(value: TokenStream) -> Self
Converts to this type from the input type.
Source§impl ToTokens for Meta
impl ToTokens for Meta
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,
Auto Trait Implementations§
impl Freeze for Meta
impl RefUnwindSafe for Meta
impl !Send for Meta
impl !Sync for Meta
impl Unpin for Meta
impl UnsafeUnpin for Meta
impl UnwindSafe for Meta
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
Mutably borrows from an owned value. Read more
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
Returns a
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.