Why isn't `RefCell` unconditionally `Unpin`?
โ Rust ๐ 2026-01-06 ๐ค surdeus ๐๏ธ 3RefCell<T> is Unpin only when T is Unpin:
impl<T> Unpin for RefCell<T>
where
T: Unpin + ?Sized,
(link)
Given that
RefCell<T>doesn't currently provide structural pinning ofT, and- It can't provide structural pinning of
Tin the future because it has interior mutabilityโaPin<&RefCell<T>>allows you to obtain&RefCell<T>, which allows you to borrow&mut Tand swap it. So there can't exist a way to get fromPin<&RefCell<T>>toPin<&T>.
Why doesn't RefCell implement Unpin unconditionally?
4 posts - 3 participants
๐ท๏ธ Rust_feed