fieldx_aux v0.2.1
Helper crate for fieldx and any third-party crates that extend its functionality.
fieldx is heavily based on the darling crate, which greatly simplifies proc-macro development,
but also imposes some constraints on attribute argument syntax. This crate overcomes these limitations
and provides support for attribute kinds required to implement fieldx.
Here is a brief breakdown of what is provided:
- Support for nested arguments, i.e. those that look like
arg1("value", trigger, subarg(...)). - Support for syntax elements not covered by the
darlingcrate, such assome_type(crate::types::Foo)anderror(crate::error::Error, crate::error::Error::SomeProblem("with details"))[^tuple]. - A set of types implementing standard
fieldxarguments like helpers or literal values.
[^tuple]: Here, the first argument of error()—Error—is an enum, and SomeProblem is one of its variants.
Usage
Imagine we are implementing a field-level attribute foo using the [darling::FromField] trait, and we want it to
accept the following arguments:
trigger: enables or disables certain functionalityaction: specifies a method with special meaningcomment: accepts arbitrary textvis: indicates whether field-related code should be public, and if so, which kind ofpubmodifier to use
A field declaration may take the following form with the attribute:
bar: usize,
For this, you'll need the following declaration somewhere in your proc-macro implementation:
#derive
That's all; this crate will take care of implementing the arguments for you!
License
Licensed under the BSD 3-Clause License.