Aggregate
Access attributes of structs, enums, unions, and their fields using a simple Derive macro and without allocating.
About
Aggregate utilizes the power of macros, perfect hash functions, and lazy loading for extreme performance.
Amalgamates are singletons representing a struct/enum/union's
attribute structure that lie in shared static memory and can be accessed via
a type function call.
Aggregate works recursively by calling aggregate() on nested structures
without limiting the types that can be used, and without runtime overhead
by simply linking to nested Amalgamates by reference.
Attributes are kept intact, which means that on access, they are
represented as syn::Attributes. However, parsing all attributes from tokens
can be costly and wasteful, which is why they are lazy-loaded and only parsed
when accessed.
Features
By default, all features are enabled.
-
derivere-exportsaggregate_derive. -
impladds default implementations for common types likeOption<T>.
Usage
aggregate is extremely simple to use.
In order to aggregate attributes of your struct/enum/union, simply derive it:
// The prelude is not required for derive,
// however in order to use `aggregate`,
// the trait must be in scope
use *;
/// This attribute is paired with the type
Aggregate supports nesting:
/// This attribute is paired with the type.
The #[aggregate] attribute is not required on enum variants,
but is again required inside enum variant structs and tuples: