rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: Alice Ryhl <aliceryhl@google.com>, mu001999 <mu001999@outlook.com>
Cc: ojeda@kernel.org, boqun.feng@gmail.com,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: kernel: make impl_has_work compatible with more complex generics
Date: Mon, 27 May 2024 09:05:38 +0000	[thread overview]
Message-ID: <d11857f1-bd9f-4cc5-ab33-44d021315796@proton.me> (raw)
In-Reply-To: <CAH5fLgiL7EdnzRL79x4zX0pXrtb8OjVkRib+qkoi=TyzHzEc4A@mail.gmail.com>

On 22.05.24 14:37, Alice Ryhl wrote:
> On Wed, May 22, 2024 at 2:27 PM mu001999 <mu001999@outlook.com> wrote:
>>  impl_has_work! {
>> -    impl<T> HasWork<Self> for ClosureWork<T> { self.work }
>> +    impl{T} HasWork<Self> for ClosureWork<T> { self.work }
>>  }
> 
> I ended up doing something similar for the generics in some of the
> linked list patches. Does anyone know if it's possible to support this
> without giving up the <T> syntax?

I tried to come up with something some time ago, but it was not really
nice. You have to parse the entire generics manually, which ends up
looking horrible. I have been thinking some time now that a `generics`
fragment would actually be really useful in declarative macros.

I also thought that if we get even more `Has*` traits for intrusive
datastructures, we could add a unified derive macro that allows you to
just do:

    #[derive(Intrusive)]
    struct MyStruct {
        #[intrusive]
        work: Work<Self>,
        #[intrusive]
        timer: Timer<Self>,
        /* ... */
    }

But I thought that as long as we have only two intrusive structures, we
don't need this.

---
Cheers,
Benno


  parent reply	other threads:[~2024-05-27  9:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 12:27 [PATCH] rust: kernel: make impl_has_work compatible with more complex generics mu001999
2024-05-22 12:37 ` Alice Ryhl
2024-05-22 13:24   ` 回复: " Xu Roland
2024-05-27  9:05   ` Benno Lossin [this message]
2024-05-22 12:38 ` Miguel Ojeda
2024-05-22 13:24   ` 回复: " Xu Roland
  -- strict thread matches above, loose matches on Subject: below --
2024-05-22 12:48 mu001999
2024-05-22 13:16 Roland Xu
2024-05-22 14:47 ` Greg KH
2024-05-22 15:55   ` Roland Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d11857f1-bd9f-4cc5-ab33-44d021315796@proton.me \
    --to=benno.lossin@proton.me \
    --cc=aliceryhl@google.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mu001999@outlook.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).