Skip to content

Commit

Permalink
Require Sync to implement Send for Cow. Fixes maciejhirsz#37
Browse files Browse the repository at this point in the history
Currently it is possible to send across references to non-sync types across thread boundaries as long as they are wrapped in a Cow. This changes the trait bounds for `Send` to be the same as they are for the standard library's Cow https://doc.rust-lang.org/std/borrow/enum.Cow.html#impl-Send
  • Loading branch information
ammaraskar authored Nov 17, 2020
1 parent 0b46851 commit 84ee8a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,5 +527,6 @@ where
}
}

// Safety: Same bounds as `std::borrow::Cow`.
unsafe impl<T: Beef + Sync + ?Sized, U: Capacity> Sync for Cow<'_, T, U> {}
unsafe impl<T: Beef + Send + ?Sized, U: Capacity> Send for Cow<'_, T, U> {}
unsafe impl<T: Beef + Sync + ?Sized, U: Capacity> Send for Cow<'_, T, U> {}

0 comments on commit 84ee8a3

Please sign in to comment.