Can Mutex be Pinned

⚓ Rust    📅 2026-02-16    👤 surdeus    👁️ 6      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Can Mutex be Pinned

For example, T: !Unpin, so Mutex<T>: !Unpin

but the code can replace T wrapped by Pin because the mutex provides &mut T

let mut x: Pin<&Mutex<T>> = todo!();
let g = x.lock().unwrap();
*g = T::new();

am I wrong?

8 posts - 4 participants

Read full topic

🏷️ Rust_feed