MetaItem in rustc_ast::ast - Rust (original) (raw)
pub struct MetaItem {
pub unsafety: Safety,
pub path: Path,
pub kind: MetaItemKind,
pub span: Span,
}
Expand description
A semantic representation of a meta item. A meta item is a slightly restricted form of an attribute – it can only contain expressions in certain leaf positions, rather than arbitrary token streams – that is used for most built-in attributes.
E.g., #[test]
, #[derive(..)]
, #[rustfmt::skip]
or #[feature = "foo"]
.
For a single-segment meta item, returns its name; otherwise, returns None
.
Example:
#[attribute(name = "value")]
^^^^^^^^^^^^^^
This is used in case you want the value span instead of the whole attribute. Example:
In here, it’ll return a span for "foo"
.
Returns the string value in:
#[attribute = "value"]
^^^^^^^
It returns None
in any other cases like:
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: 88 bytes