Re: [PATCH v2 4/4] rust: devres: implement register_release()

From: Benno Lossin
Date: Sun Jun 22 2025 - 16:48:12 EST


On Sun Jun 22, 2025 at 6:40 PM CEST, Danilo Krummrich wrote:
> +impl<T: Release> Release for crate::sync::ArcBorrow<'_, T> {
> + fn release(&self) {
> + self.deref().release();
> + }
> +}
> +
> +impl<T: Release> Release for Pin<&'_ T> {

You don't need the `'_` here.

> + fn release(&self) {
> + self.deref().release();
> + }
> +}

I still think we're missing a `impl<T: Release> Release for &T`.

And maybe a closure design is better, depending on how much code is
usually run in `release`, if it's a lot, then we should use the trait
design. If it's only 1-5 lines, then a closure would also be fine. I
don't have a strong preference, but if it's mostly one liners, then
closures would be better.

If you keep the trait design & we resolve the `&T: Release` question:

Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>

---
Cheers,
Benno