[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiq72kF2f7vtyE97E_8nohfZLrXGczk8qbf7=UG=SX0uPLeUA@mail.gmail.com>
Date: Tue, 20 Jan 2026 17:00:40 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Gary Guo <gary@...yguo.net>
Cc: Danilo Krummrich <dakr@...nel.org>, Greg KH <gregkh@...uxfoundation.org>,
Onur Özkan <work@...rozkan.dev>,
rust-for-linux@...r.kernel.org, rafael@...nel.org, ojeda@...nel.org,
boqun.feng@...il.com, bjorn3_gh@...tonmail.com, lossin@...nel.org,
a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] rust: simplify `Adapter::id_info`
On Tue, Jan 20, 2026 at 4:01 PM Gary Guo <gary@...yguo.net> wrote:
>
> For this specific instance, it looks like it could just be
>
> let level1 = VVec::<u8>::with_capacity(
> level2.iter().count() * size_of::<u64>(),
> GFP_KERNEL,
> )?;
> let level1 = map_into_lvl(&level2, level1)?;
> SGTable::new(dev, level1, DataDirection::ToDevice, GFP_KENREL)?
>
> which IMO looks clearer.
>
> I suspect what people want is Elixir's pipe operator so the above is like this
> (non-existent, imaginary syntax):
>
> VVec::<u8>::with_capacity(
> level2.iter().count() * size_of::<u64>(),
> GFP_KERNEL,
> )?
> |> map_into_lvl(&level2, _)?
> |> SGTable::new(dev, _, DataDirection::ToDevice, GFP_KERNEL)?
>
> But I think keeping things as `Result` (and not using `?`) just to use the
> functional combinatiors is probably a bad idea.
Agreed -- I think when `?` is applicable, it can make things cleaner
to get things "out" of the type (and, after all, we did get the
"symbol soup" complaints about closures in the past... :).
Cheers,
Miguel
Powered by blists - more mailing lists