On Thu, Jun 26, 2025 at 04:41:55PM +0200, Benno Lossin wrote: > On Thu Jun 26, 2025 at 4:02 PM CEST, Danilo Krummrich wrote: > > On Thu, Jun 26, 2025 at 01:15:34PM +0200, Danilo Krummrich wrote: > >> On Thu, Jun 26, 2025 at 12:36:23PM +0200, Benno Lossin wrote: > >> > Or, we could change `Release` to be: > >> > > >> > pub trait Release { > >> > type Ptr: ForeignOwnable; > >> > > >> > fn release(this: Self::Ptr); > >> > } > >> > > >> > and then `register_release` is: > >> > > >> > pub fn register_release<T: Release>(dev: &Device<Bound>, data: T::Ptr) -> Result > >> > > >> > This way, one can store a `Box<T>` and get access to the `T` at the end. > >> > >> I think this was also the case before? Well, it was P::Borrowed instead. > >> > >> > Or if they store the value in an `Arc<T>`, they have the option to clone > >> > it and give it to somewhere else. > >> > >> Anyways, I really like this proposal of implementing the Release trait. > > > > One downside seems to be that the compiler cannot infer T anymore with this > > function signature. > > Yeah... That's a bit annoying. > > We might be able to add an associated type to `ForeignOwnable` like > `Target` or `Inner` or whatever. I think we already have `PointedTo` [1]? But I remember that I've seen a patch to remove it again [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/kernel/types.rs#n32 [2] https://lore.kernel.org/all/20250612-pointed-to-v3-1-b009006d86a1@xxxxxxxxxx/ > Then we could do: > > pub fn register_release<P>(dev: &Device<Bound>, data: P) -> Result > where > P: ForeignOwnable, > P::Inner: Release<Ptr = P>, > > --- > Cheers, > Benno