Expand description
Amplifying Rust language capabilities: helper functions for creating proc macro libraries
§Examples
#[name]
- single form
#[name = "literal"]
- optional single value
#[name = TypeName]
- path value
#[name("literal", TypeName, arg = value)]
- list of arguments
Macros§
- ident
- Convenience macro for constructing
syn::Ident
from literals - path
- Convenience macro for constructing
syn::Path
from literals
Structs§
- AttrReq
- Structure requirements for parametrized attribute
- Data
Type - Field
- Items
- Meta
ArgList - Drop-in replacement for
syn::NestedMeta
, which allows to parse attributes which can have arguments made of either literal, path orMetaArgNameValue
expressions. - Meta
ArgName Value - Drop-in replacement for
syn::MetaNameValue
used for parsing named arguments inside attributes which name is always anproc_macro2::Ident
(and notsyn::Path
) and value can be not only a literal, but of any valid rust type. - Named
Field - Parametrized
Attr - Representation for all allowed forms of
#[attr(...)]
attribute. If attribute has a multiple occurrences they are all assembled into a single list. Repeated named arguments are not allowed and result in errors. - Singular
Attr - Structure describing a procedural macro attribute with an optional value.
The means that if one has something like
#[name1]
,#[name2 = "value"]
,#[name3 = ::std::path::PathBuf)]
thanname1
,name2 = "value"
, andname3 = ::std::path::PathBuf
are three different attributes which can be parsed and represented by theSingularAttr
structure. - Variant
Enums§
- ArgValue
- Value for attribute or attribute argument, i.e. for
#[attr = value]
and#[attr(arg = value)]
this is thevalue
part of the attribute. Can be either a single literal or a single valid rust type name - ArgValue
Req - Requirements for attribute or named argument value presence
- Attr
- Internal structure representation of a proc macro attribute collected
instances having some specific name (accessible via
Attr::name()
). - Data
Inner - Enum
Kind - Error
- Errors representing inconsistency in proc macro attribute structure
- Field
Kind - Fields
- ListReq
- Requirements for list elements. For instance, used in
AttrReq
for providingcrate::ParametrizedAttr
fields requirements. - Literal
Class - Constrains for literal value type
- MetaArg
- Drop-in replacement for
syn::NestedMeta
, which allows to parse attributes which can have arguments made of either literal, path orMetaArgNameValue
expressions. - Scope
- Type
Class - Constrains for the possible types that a Rust value could have.
- Value
Class - Constrains for attribute value type
- Value
Req - Requirements for attribute or named argument value presence for a values
with known class. If the value class is not known, use
ArgValueReq
instead. - Vis