Re: [PATCH v12 1/4] rust: types: Add Ownable/Owned types

From: Danilo Krummrich

Date: Thu Oct 30 2025 - 11:42:03 EST


On 10/1/25 11:03 AM, Oliver Mangold wrote:
> From: Asahi Lina <lina+kernel@xxxxxxxxxxxxx>
>
> By analogy to `AlwaysRefCounted` and `ARef`, an `Ownable` type is a
> (typically C FFI) type that *may* be owned by Rust, but need not be. Unlike
> `AlwaysRefCounted`, this mechanism expects the reference to be unique
> within Rust, and does not allow cloning.
>
> Conceptually, this is similar to a `KBox<T>`, except that it delegates
> resource management to the `T` instead of using a generic allocator.
>
> [ om:
> - Split code into separate file and `pub use` it from types.rs.
> - Make from_raw() and into_raw() public.
> - Remove OwnableMut, and make DerefMut dependent on Unpin instead.
> - Usage example/doctest for Ownable/Owned.
> - Fixes to documentation and commit message.
> ]
>
> Link: https://lore.kernel.org/all/20250202-rust-page-v1-1-e3170d7fe55e@xxxxxxxxxxxxx/
> Signed-off-by: Asahi Lina <lina+kernel@xxxxxxxxxxxxx>
> Co-developed-by: Oliver Mangold <oliver.mangold@xxxxx>
> Signed-off-by: Oliver Mangold <oliver.mangold@xxxxx>
> Reviewed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
I think this patch was originally sent by Abdiel and Boqun [1]; we should
probably take this into account. :)

[1]
https://lore.kernel.org/rust-for-linux/20241022224832.1505432-2-abdiel.janulgue@xxxxxxxxx/