[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiq72=WxRPzqVb8W=TRcU54Dr_9A1Fmm8ZVx-NMVbD38YrCFg@mail.gmail.com>
Date: Mon, 7 Oct 2024 20:47:21 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Timo Grautstueck <timo.grautstueck@....de>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Miguel Ojeda <ojeda@...nel.org>
Subject: Re: [PATCH] rust: types: 'real-life' example for Either
On Mon, Oct 7, 2024 at 5:54 PM Timo Grautstueck <timo.grautstueck@....de> wrote:
>
> Added a 'real-life' example for the type `Either`. This example
> uses a work queue and extends the first example in `workqueue.rs`
> (commit ID: 15b286d) to demonstrate how to hold and distinguish
> between two different data types.
>
> Suggested-by: Miguel Ojeda <ojeda@...nel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1122
> Signed-off-by: Timo Grautstueck <timo.grautstueck@....de>
This is a nice, self-contained example, thanks!
In the linked issue, I was aiming more to have a case where `Either`
was used in an interface (or similar) carrying two existing different
types, i.e. like in the talk I mentioned in the issue. I feel a custom
`enum` may work better anyway for something like the example in this
patch, i.e. when one does not have already types on each side that
make it obvious what each side is about.
So perhaps we can modify this example with two "message" or "action"
types (that may be hidden) or something similar that `Either` can
carry, so that it is a bit more concrete.
It wouldn't hurt either to showcase in addition the interface the talk
showed, perhaps in an `ignore` example so that we don't have to "mock"
everything.
Cheers,
Miguel
Powered by blists - more mailing lists