feat(allocator): add Send + Sync to HashMap

This commit is contained in:
Boshen 2025-01-18 14:23:52 +08:00
parent 6c4081e148
commit 3d64cefe10
No known key found for this signature in database
GPG key ID: 67715A371E534061

View file

@ -50,6 +50,11 @@ type FxHashMap<'alloc, K, V> = hashbrown::HashMap<K, V, FxBuildHasher, &'alloc B
/// [`FxHasher`]: rustc_hash::FxHasher
pub struct HashMap<'alloc, K, V>(ManuallyDrop<FxHashMap<'alloc, K, V>>);
/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
unsafe impl<K, V> Send for HashMap<'_, K, V> {}
/// SAFETY: Not actually safe, but for enabling `Sync` for downstream crates.
unsafe impl<K, V> Sync for HashMap<'_, K, V> {}
// TODO: `IntoIter`, `Drain`, and other consuming iterators provided by `hashbrown` are `Drop`.
// Wrap them in `ManuallyDrop` to prevent that.