mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
rust: sync: add UniqueArc::as_ptr
Add an associated function to `UniqueArc` for getting a raw pointer. The implementation defers to the `Arc` implementation. Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260605-unique-arc-as-ptr-v2-1-425476d2abdb@kernel.org [ Relaxed bound moving it to new `T: ?Sized` impl block. Reworded since it is not a method anymore. Added intra-doc link. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
0bf626dc90
commit
759da9e0fa
|
|
@ -760,6 +760,14 @@ pub fn new_uninit(flags: Flags) -> Result<UniqueArc<MaybeUninit<T>>, AllocError>
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> UniqueArc<T> {
|
||||
/// Return a raw pointer to the data in this [`UniqueArc`].
|
||||
#[inline]
|
||||
pub fn as_ptr(this: &Self) -> *const T {
|
||||
Arc::as_ptr(&this.inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> UniqueArc<MaybeUninit<T>> {
|
||||
/// Converts a `UniqueArc<MaybeUninit<T>>` into a `UniqueArc<T>` by writing a value into it.
|
||||
pub fn write(mut self, value: T) -> UniqueArc<T> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user