Re: [PATCH] rust: sync: add #[must_use] to Lock::try_lock

Tamir Duberstein
2024-12-08T21:58:17Z

On Sun, Dec 8, 2024 at 3:50 PM Jason Devers <dev.json2@gmail.com> wrote:
>
> The `Lock::try_lock` function returns an `Option<Guard<...>>`, but it
> currently does not issue a warning if the return value is unused.
> To avoid potential bugs, the `#[must_use]` annotation is added to ensure proper usage.

It'd be great to mention in this message (and perhaps in the code)
that the reason this annotation is necessary is that `Option<T>` is
not `#[must_use]` regardless of `T` being `#[must_use]`. It might also
be handy to leave a breadcrumb pointing to