rust: pin-init: examples: use Wrapper::pin_init instead of manual reimplementation

`UnsafeCell` gains the method via the extension trait `Wrapper`.

Link: https://patch.msgid.link/20260729-merge-init-v2-1-26adf47109e7@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
This commit is contained in:
Gary Guo
2026-08-03 13:36:34 +01:00
parent 6d0795b507
commit c998b661b7
+1 -5
View File
@@ -79,11 +79,7 @@ impl<T> CMutex<T> {
wait_list <- ListHead::new(),
spin_lock: SpinLock::new(),
locked: Cell::new(false),
data <- unsafe {
pin_init_from_closure(|slot: *mut UnsafeCell<T>| {
val.__pinned_init(slot.cast::<T>())
})
},
data <- UnsafeCell::pin_init(val),
})
}