-
Notifications
You must be signed in to change notification settings - Fork 0
New trait OwnableRefCounted for ARef<->Owned conversion. #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: linus-master_base
Are you sure you want to change the base?
Conversation
|
Upstream branch: f824272 |
d782508 to
6099a4d
Compare
|
Upstream branch: e7c375b |
5b3b0ed to
195123f
Compare
6099a4d to
5121c4d
Compare
|
Upstream branch: e7c375b |
195123f to
12ab472
Compare
5121c4d to
4458758
Compare
|
Upstream branch: 8b69055 |
12ab472 to
9b983be
Compare
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/[email protected]/ Signed-off-by: Asahi Lina <[email protected]> Co-developed-by: Oliver Mangold <[email protected]> Signed-off-by: Oliver Mangold <[email protected]> Co-developed-by: Andreas Hindborg <[email protected]> Signed-off-by: Andreas Hindborg <[email protected]> Reviewed-by: Boqun Feng <[email protected]>
`AlwaysRefCounted` will become a marker trait to indicate that it is allowed to obtain an `ARef<T>` from a `&T`, which cannot be allowed for types which are also Ownable. Signed-off-by: Oliver Mangold <[email protected]> Co-developed-by: Andreas Hindborg <[email protected]> Signed-off-by: Andreas Hindborg <[email protected]> Suggested-by: Alice Ryhl <[email protected]>
SAFETY comment in rustdoc example was just 'TODO'. Fixed. Signed-off-by: Oliver Mangold <[email protected]> Co-developed-by: Andreas Hindborg <[email protected]> Signed-off-by: Andreas Hindborg <[email protected]>
Types implementing one of these traits can safely convert between an `ARef<T>` and an `Owned<T>`. This is useful for types which generally are accessed through an `ARef` but have methods which can only safely be called when the reference is unique, like e.g. `block::mq::Request::end_ok()`. Signed-off-by: Oliver Mangold <[email protected]> Co-developed-by: Andreas Hindborg <[email protected]> Signed-off-by: Andreas Hindborg <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]>
|
Upstream branch: fd95357 |
9b983be to
5ce4d2a
Compare
Pull request for series with
subject: New trait OwnableRefCounted for ARef<->Owned conversion.
version: 13
url: https://patchwork.kernel.org/project/linux-block/list/?series=1024189