From 759da9e0fa79223138ec8c18b9075cd7dace6070 Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Fri, 5 Jun 2026 15:16:48 +0200 Subject: [PATCH] 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 Reviewed-by: Alice Ryhl 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 --- rust/kernel/sync/arc.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index feca07e8d13d..5ac4961b7cd2 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -760,6 +760,14 @@ pub fn new_uninit(flags: Flags) -> Result>, AllocError> } } +impl UniqueArc { + /// 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 UniqueArc> { /// Converts a `UniqueArc>` into a `UniqueArc` by writing a value into it. pub fn write(mut self, value: T) -> UniqueArc {