On Tue Feb 17, 2026 at 1:21 AM GMT, Joel Fernandes wrote:
> On Wed, 28 Jan 2026 13:53:23 -0800, Boqun Feng wrote:
>> Therefore here is the effort to unify them into a proc-macro based
>> solution. Field and HasField traits are introduced to generify the
>> "Has A" relationship, and a derive macro #[derive(HasField)] is also
>> added to support automatically implementing HasField trait.
>
> Hi Boqun,
>
> One naming concern: the #[field] attribute feels ambiguous since in
> Rust every struct member is already called a "field." When reading:
>
> #[derive(HasField)]
> struct MyStruct {
> value: i32,
> #[field]
> work: Work<MyStruct>,
> }
>
> it's not immediately obvious why "work" gets #[field] but "value"
> does not, as both are struct fields.
>
> Would something like #[project] be clearer?
>
> Similarly, HasField could become HasProjection or ProjectField to
> better distinguish the trait's purpose from the general concept of fields.
This is not just for projection, but to establish has-a relation. A struct can
project into any of its fields, but for work/hrtimer use cases, it needs to be
able to find a specific field.
If we want a different name then I'd suggest `#[has]`.
Best,
Gary