[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D8F91L51P2EA.2FBHGJYSV06HY@proton.me>
Date: Thu, 13 Mar 2025 15:38:55 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alexandre Courbot <acourbot@...dia.com>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, Danilo Krummrich <dakr@...nel.org>, Björn Roy Baron <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust/revocable: add try_with() convenience method
On Thu Mar 13, 2025 at 4:08 PM CET, Alexandre Courbot wrote:
> On Thu Mar 13, 2025 at 11:19 PM JST, Benno Lossin wrote:
>> Would it make sense to not use `Result` here and continue with `Option`?
>
> We would have to return an Option<Result<R>> in this case. The current
> code folds the closure's Result into the one of the guard's acquisition
> for convenience.
>
> Actually, I don't think I have ever used try_access() a single time
> without converting its returned Option into a Result. Wouldn't it make
> sense to do the opposite, i.e. make try_access() return Err(ENXIO) when
> the guard cannot be acquired and document this behavior?
Sure, if you're always doing
let guard = rev.try_access().ok_or(ENXIO)?;
Then it makes sense from my view, maybe Danilo has some other argument
for why `Option` is better.
---
Cheers,
Benno
Powered by blists - more mailing lists