From: Andreas Hindborg Date: Fri, 5 Jun 2026 13:16:48 +0000 (+0200) Subject: rust: sync: add `UniqueArc::as_ptr` X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=759da9e0fa79223138ec8c18b9075cd7dace6070;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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 @@ impl UniqueArc { } } +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 {