Skip to content

Commit

Permalink
Add unsafe Send and Sync impls to VecDeque's Drain<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
mystor committed Oct 8, 2015
1 parent 45be6fc commit 493355d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/libcollections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,9 @@ pub struct Drain<'a, T: 'a> {
deque: *mut VecDeque<T>,
}

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) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-pass/sync-send-iterators-in-libcollections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ fn main() {
}
all_sync_send!(EnumSet::<Foo>::new(), iter);

all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, drain, into_iter);
all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, into_iter);
is_sync_send!(VecDeque::<usize>::new(), drain(..));

all_sync_send!(Vec::<usize>::new(), into_iter);
is_sync_send!(Vec::<usize>::new(), drain(..));
Expand Down

0 comments on commit 493355d

Please sign in to comment.