| Crates.io | fieldx_aux |
| lib.rs | fieldx_aux |
| version | 0.2.3 |
| created_at | 2024-08-02 02:02:38.476028+00 |
| updated_at | 2025-07-30 15:32:05.646266+00 |
| description | Various types and tools useful for fieldx crates and, potentially, to users of fieldx |
| homepage | https://vrurg.github.io/fieldx/ |
| repository | https://github.com/vrurg/fieldx.git |
| max_upload_size | |
| id | 1322726 |
| size | 115,737 |
Helper crate for fieldx and any third-party crates that extend its functionality. Can be used either to extend
FieldX functionality or to implement your own proc-macros.
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:
arg1("value", trigger, subarg(...)).darling crate, such as
some_type(crate::types::Foo) and
error(crate::error::Error, crate::error::Error::SomeProblem("with details"))1.fieldx arguments like helpers or literal values.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 of pub modifier to useA field declaration may take the following form with the attribute:
#[foo(
trigger,
action("method_name", private),
comment("Whatever we consider useful."),
vis(pub(crate))
)]
bar: usize,
For this, you’ll need the following declaration somewhere in your proc-macro implementation:
#derive(FromField)
#[darling(attributes(foo))]
struct FooField {
// ... skipping some darling default fields ...
trigger: Option<FXBool>,
action: Option<FXHelper>,
comment: Option<FXString>,
vis: Option<FXSynValue<syn::Visibility>>,
}
That’s all; this crate will take care of implementing the arguments for you!
Read the FieldX Object Manager book for the introduction on how to use this crate.
Licensed under the BSD 3-Clause License.
Here, the first argument of error()—Error—is an enum, and SomeProblem is one of its variants. ↩