Skip to content

Commit

Permalink
feat(metadata): remove manual Send + Sync impls for metadata types (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn authored May 12, 2021
1 parent 57509d3 commit e97f518
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tonic/src/metadata/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,6 @@ impl<'a> Iterator for Iter<'a> {
}
}

unsafe impl<'a> Sync for Iter<'a> {}
unsafe impl<'a> Send for Iter<'a> {}

// ===== impl IterMut =====

impl<'a> Iterator for IterMut<'a> {
Expand Down Expand Up @@ -1274,9 +1271,6 @@ impl<'a> Iterator for IterMut<'a> {
}
}

unsafe impl<'a> Sync for IterMut<'a> {}
unsafe impl<'a> Send for IterMut<'a> {}

// ===== impl ValueDrain =====

impl<'a, VE: ValueEncoding> Iterator for ValueDrain<'a, VE> {
Expand All @@ -1293,9 +1287,6 @@ impl<'a, VE: ValueEncoding> Iterator for ValueDrain<'a, VE> {
}
}

unsafe impl<'a, VE: ValueEncoding> Sync for ValueDrain<'a, VE> {}
unsafe impl<'a, VE: ValueEncoding> Send for ValueDrain<'a, VE> {}

// ===== impl Keys =====

impl<'a> Iterator for Keys<'a> {
Expand Down Expand Up @@ -1425,9 +1416,6 @@ where
}
}

unsafe impl<'a, VE: ValueEncoding> Sync for ValueIterMut<'a, VE> {}
unsafe impl<'a, VE: ValueEncoding> Send for ValueIterMut<'a, VE> {}

// ===== impl Entry =====

impl<'a, VE: ValueEncoding> Entry<'a, VE> {
Expand Down Expand Up @@ -2725,4 +2713,18 @@ mod tests {
}
assert!(found_x_word_bin);
}

#[allow(dead_code)]
fn value_drain_is_send_sync() {
fn is_send_sync<T: Send + Sync>() {}

is_send_sync::<Iter<'_>>();
is_send_sync::<IterMut<'_>>();

is_send_sync::<ValueDrain<'_, Ascii>>();
is_send_sync::<ValueDrain<'_, Binary>>();

is_send_sync::<ValueIterMut<'_, Ascii>>();
is_send_sync::<ValueIterMut<'_, Binary>>();
}
}

0 comments on commit e97f518

Please sign in to comment.