Skip to content

Commit ee6a1e1

Browse files
author
Oliver Mangold
committed
New trait OwnableRefCounted for ARef<->Owned conversion.
This allows to convert between ARef<T> and Owned<T> by implementing the new trait OwnedRefCounted. This way we will have a shared/unique reference counting scheme for types with built-in refcounts in analogy to Arc/UniqueArc. To: Miguel Ojeda <ojeda@kernel.org> To: Alex Gaynor <alex.gaynor@gmail.com> To: Boqun Feng <boqun.feng@gmail.com> To: Gary Guo <gary@garyguo.net> To: Björn Roy Baron <bjorn3_gh@protonmail.com> To: Benno Lossin <benno.lossin@proton.me> To: Andreas Hindborg <a.hindborg@kernel.org> To: Alice Ryhl <aliceryhl@google.com> To: Trevor Gross <tmgross@umich.edu> To: Asahi Lina <lina@asahilina.net> Cc: rust-for-linux@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Oliver Mangold <oliver.mangold@pm.me> --- Changes in v8: - EDITME: describe what is new in this series revision. - EDITME: use bulletpoints and terse descriptions. - Link to v7: https://lore.kernel.org/r/20250310-unique-ref-v7-0-4caddb78aa05@pm.me Changes in v7: - Squash patch to make Owned::from_raw/into_raw public into parent - Added Signed-off-by to other people's commits - Link to v6: https://lore.kernel.org/r/20250310-unique-ref-v6-0-1ff53558617e@pm.me Changes in v6: - Changed comments/formatting as suggested by Miguel Ojeda - Included and used new config flag RUSTC_HAS_DO_NOT_RECOMMEND, thus no changes to types.rs will be needed when the attribute becomes available. - Fixed commit message for Owned patch. - Link to v5: https://lore.kernel.org/r/20250307-unique-ref-v5-0-bffeb633277e@pm.me Changes in v5: - Rebase the whole thing on top of the Ownable/Owned traits by Asahi Lina. - Rename AlwaysRefCounted to RefCounted and make AlwaysRefCounted a marker trait instead to allow to obtain an ARef<T> from an &T, which (as Alice pointed out) is unsound when combined with UniqueRef/Owned. - Change the Trait design and naming to implement this feature, UniqueRef/UniqueRefCounted is dropped in favor of Ownable/Owned and OwnableRefCounted is used to provide the functions to convert between Owned and ARef. - Link to v4: https://lore.kernel.org/r/20250305-unique-ref-v4-1-a8fdef7b1c2c@pm.me Changes in v4: - Just a minor change in naming by request from Andreas Hindborg, try_shared_to_unique() -> try_from_shared(), unique_to_shared() -> into_shared(), which is more in line with standard Rust naming conventions. - Link to v3: https://lore.kernel.org/r/Z8Wuud2UQX6Yukyr@mango --- b4-submit-tracking --- # This section is used internally by b4 prep for tracking purposes. { "series": { "revision": 8, "change-id": "20250305-unique-ref-29fcd675f9e9", "prefixes": [], "history": { "v4": [ "Z8Wuud2UQX6Yukyr@mango", "20250305-unique-ref-v4-1-a8fdef7b1c2c@pm.me" ], "v5": [ "20250307-unique-ref-v5-0-bffeb633277e@pm.me" ], "v6": [ "20250310-unique-ref-v6-0-1ff53558617e@pm.me" ], "v7": [ "20250310-unique-ref-v7-0-4caddb78aa05@pm.me" ] } } }
1 parent 4b2ee22 commit ee6a1e1

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)