Rollup merge of #58369 - nox:sync-hash-map-entry, r=Amanieu

Make the Entry API of HashMap<K, V> Sync and Send

Fixes #45219
This commit is contained in:
Pietro Albini 2019-03-08 09:41:42 +01:00 committed by GitHub
commit 55dc386f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2341,6 +2341,11 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, K: 'a + Send, V: 'a + Send> Send for OccupiedEntry<'a, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for OccupiedEntry<'a, K, V> {}
#[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -2362,6 +2367,11 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, K: 'a + Send, V: 'a + Send> Send for VacantEntry<'a, K, V> {}
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for VacantEntry<'a, K, V> {}
#[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<K: Debug, V> Debug for VacantEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -53,6 +53,7 @@ fn main() {
is_sync_send!(BTreeSet::<usize>::new(), union(&BTreeSet::<usize>::new()));
all_sync_send!(HashMap::<usize, usize>::new(), iter, iter_mut, drain, into_iter, keys, values);
is_sync_send!(HashMap::<usize, usize>::new(), entry(0));
all_sync_send!(HashSet::<usize>::new(), iter, drain, into_iter);
is_sync_send!(HashSet::<usize>::new(), difference(&HashSet::<usize>::new()));
is_sync_send!(HashSet::<usize>::new(), symmetric_difference(&HashSet::<usize>::new()));