From 493355d8e92ab00f0f6b787e4226c095ccd83a55 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Thu, 24 Sep 2015 18:19:23 -0400 Subject: [PATCH] Add unsafe Send and Sync impls to VecDeque's Drain --- src/libcollections/vec_deque.rs | 3 +++ src/test/run-pass/sync-send-iterators-in-libcollections.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 27a996055f5..807c02af6e1 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1800,6 +1800,9 @@ pub struct Drain<'a, T: 'a> { deque: *mut VecDeque, } +unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} +unsafe impl<'a, T: Send> Send for Drain<'a, T> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: 'a> Drop for Drain<'a, T> { fn drop(&mut self) { diff --git a/src/test/run-pass/sync-send-iterators-in-libcollections.rs b/src/test/run-pass/sync-send-iterators-in-libcollections.rs index 8160fe56fd0..7fa592105c0 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcollections.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcollections.rs @@ -93,7 +93,8 @@ fn from_usize(v: usize) -> Foo { } all_sync_send!(EnumSet::::new(), iter); - all_sync_send!(VecDeque::::new(), iter, iter_mut, drain, into_iter); + all_sync_send!(VecDeque::::new(), iter, iter_mut, into_iter); + is_sync_send!(VecDeque::::new(), drain(..)); all_sync_send!(Vec::::new(), into_iter); is_sync_send!(Vec::::new(), drain(..));