Re: [PATCH 1/6] rust: types: Add Ownable/Owned types
From: Alice Ryhl
Date: Mon Feb 03 2025 - 13:17:36 EST
On Mon, Feb 3, 2025 at 3:17 PM Asahi Lina <lina@xxxxxxxxxxxxx> wrote:
>
>
>
> On 2/3/25 6:13 PM, Alice Ryhl wrote:
> > On Sun, Feb 2, 2025 at 2:06 PM Asahi Lina <lina@xxxxxxxxxxxxx> wrote:
> >> + /// Consumes the `Owned`, returning a raw pointer.
> >> + ///
> >> + /// This function does not actually relinquish ownership of the object.
> >> + /// After calling this function, the caller is responsible for ownership previously managed
> >> + /// by the `Owned`.
> >> + #[allow(dead_code)]
> >> + pub(crate) fn into_raw(me: Self) -> NonNull<T> {
> >
> > I would just make these methods public, like the ARef ones. Then you
> > can drop the #[allow(dead_code)] annotation.
>
> Does it make sense to ever have drivers doing this? I feel like these
> methods should be limited to the kernel crate.
Not having drivers use this is the ideal, but I don't think we should
always expect it to be possible. The Binder driver has a C component
for the binderfs component, and it also has some code that's
essentially an abstraction inside the driver that I was asked to move
into Binder because it's so specific to Binder that it's not useful
for anyone else.
Alice