diff options
| author | Gary Guo <gary@garyguo.net> | 2026-07-29 16:38:43 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2026-08-03 13:36:34 +0100 |
| commit | c998b661b7c024dfd6dd893927506e32ee8a42c5 (patch) | |
| tree | 08e874a8958636e10f806ed6748d7d0350a60bc0 /rust | |
| parent | 6d0795b507fb1db2e6aefe533d949db3a4abf4c6 (diff) | |
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>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/pin-init/examples/mutex.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/rust/pin-init/examples/mutex.rs b/rust/pin-init/examples/mutex.rs index 882f3e23f5dd..e8d4dbb664fe 100644 --- a/rust/pin-init/examples/mutex.rs +++ b/rust/pin-init/examples/mutex.rs @@ -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), }) } |
