Meta

Enum Meta 

Source
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

Source

pub fn path(&self) -> Result<&Path>

Source

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.

Source

pub fn is_path_or_list(&self) -> bool

Source

pub fn is_path_or_empty_list(&self) -> bool

Source

pub fn as_path(&self) -> Result<&Path>

Source

pub fn as_path_list(&self) -> Result<&PathList>

Source

pub fn as_path_value(&self) -> Result<&PathValue>

Source

pub fn as_expr(&self) -> Result<&Expr>

Source

pub fn as_verbatim(&self, msg: impl Display) -> Result<&TokenStream>

Source

pub fn assert_directive(&self, directive: &str) -> Result<&Self>

Trait Implementations§

Source§

impl Debug for Meta

Source§

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

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

impl From<Expr> for Meta

Source§

fn from(value: Expr) -> Self

Converts to this type from the input type.
Source§

impl From<PathList> for Meta

Source§

fn from(value: PathList) -> Self

Converts to this type from the input type.
Source§

impl From<PathValue> for Meta

Source§

fn from(value: PathValue) -> Self

Converts to this type from the input type.
Source§

impl From<TokenStream> for Meta

Source§

fn from(value: TokenStream) -> Self

Converts to this type from the input type.
Source§

impl Parse for Meta

Source§

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

Source§

impl ToTokens for Meta

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

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl !Send for Meta

§

impl !Sync for Meta

§

impl Unpin for Meta

§

impl UnwindSafe for Meta

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> 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> ToTokensExtension<T> for T
where T: ToTokens,

Source§

fn get_self(&self) -> &T

Source§

fn error(&self, message: impl Display) -> Error

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.