Skip to content

Commit 493355d

Browse files
committed
Add unsafe Send and Sync impls to VecDeque's Drain<T>
1 parent 45be6fc commit 493355d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libcollections/vec_deque.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,9 @@ pub struct Drain<'a, T: 'a> {
18001800
deque: *mut VecDeque<T>,
18011801
}
18021802

1803+
unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {}
1804+
unsafe impl<'a, T: Send> Send for Drain<'a, T> {}
1805+
18031806
#[stable(feature = "rust1", since = "1.0.0")]
18041807
impl<'a, T: 'a> Drop for Drain<'a, T> {
18051808
fn drop(&mut self) {

src/test/run-pass/sync-send-iterators-in-libcollections.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ fn main() {
9393
}
9494
all_sync_send!(EnumSet::<Foo>::new(), iter);
9595

96-
all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, drain, into_iter);
96+
all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, into_iter);
97+
is_sync_send!(VecDeque::<usize>::new(), drain(..));
9798

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

0 commit comments

Comments
 (0)