Why does BTreeSet use ManuallyDrop?
⚓ Rust 📅 2026-02-01 👤 surdeus 👁️ 8From set.rs - source
fn sub(self, rhs: &BTreeSet<T, A>) -> BTreeSet<T, A> {
BTreeSet::from_sorted_iter(
self.difference(rhs).cloned(),
ManuallyDrop::into_inner(self.map.alloc.clone()),
)
}
I don't understand what is going on here.
3 posts - 2 participants
🏷️ Rust_feed