Skip to content

Commit 4fedd76

Browse files
Andreas Hindborgojeda
authored andcommitted
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>
1 parent 1c93549 commit 4fedd76

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

rust/kernel/sync/arc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,14 @@ impl<T> UniqueArc<T> {
760760
}
761761
}
762762

763+
impl<T: ?Sized> UniqueArc<T> {
764+
/// Return a raw pointer to the data in this [`UniqueArc`].
765+
#[inline]
766+
pub fn as_ptr(this: &Self) -> *const T {
767+
Arc::as_ptr(&this.inner)
768+
}
769+
}
770+
763771
impl<T> UniqueArc<MaybeUninit<T>> {
764772
/// Converts a `UniqueArc<MaybeUninit<T>>` into a `UniqueArc<T>` by writing a value into it.
765773
pub fn write(mut self, value: T) -> UniqueArc<T> {

0 commit comments

Comments
 (0)