[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y5z/msA6FWH0Bgmq@liuwe-devbox-debian-v2>
Date: Fri, 16 Dec 2022 23:30:34 +0000
From: Wei Liu <wei.liu@...nel.org>
To: Boqun Feng <boqun.feng@...il.com>
Cc: Wedson Almeida Filho <wedsonaf@...il.com>,
Wei Liu <wei.liu@...nel.org>, rust-for-linux@...r.kernel.org,
Linux Kernel List <linux-kernel@...r.kernel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>
Subject: Re: [PATCH] rust: kernel: drop repetition in offset_of macro
On Fri, Dec 16, 2022 at 02:15:16PM -0800, Boqun Feng wrote:
> On Fri, Dec 16, 2022 at 06:26:57PM +0000, Wedson Almeida Filho wrote:
> > On Fri, 16 Dec 2022 at 17:49, Wei Liu <wei.liu@...nel.org> wrote:
> > >
> > > It doesn't make sense to allow multiple fields to be specified in
> > > offset_of.
> >
> > Why do you say it doesn't make sense?
> >
> > Here's what I had in mind:
> > ```
> > struct Y {
> > z: u32
> > }
> > struct X {
> > y: Y
> > }
> > offset_of!(X, y.z)
>
> For me, it's not very obvious that "y.z" is multiples of token trees
> rather a single token tree ;-)
>
> Maybe some examples of the match pattern of macros can help people catch
> up faster? Like
>
> "y.z" => tt [y], tt [.], tt [z]
>
> I will defer to Gary or Bjorn for a better quick guide of Rust macros
> ;-)
>
What will be even better is someone please contribute such a macro to
libcore so that I don't have to replicate the code snippet everywhere.
:-)
I have a version somewhere, the second argument matches against ident,
which was definitely not as flexible as tt.
Thanks,
Wei.
Powered by blists - more mailing lists