//@ run-pass #![allow(warnings)] #![feature(drain, collections_bound, btree_range)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; use std::mem; use std::ops::Bound::Included; fn is_sync(_: T) where T: Sync, { } fn is_send(_: T) where T: Send, { } macro_rules! all_sync_send { ($ctor:expr, $($iter:ident),+) => ({ $( let mut x = $ctor; is_sync(x.$iter()); let mut y = $ctor; is_send(y.$iter()); )+ }) } macro_rules! is_sync_send { ($ctor:expr, $iter:ident($($param:expr),+)) => ({ let mut x = $ctor; is_sync(x.$iter($( $param ),+)); let mut y = $ctor; is_send(y.$iter($( $param ),+)); }) } fn main() { // The iterator "coroutine" list should exhaust what corresponding // implementations have where `Sync` and `Send` semantics apply. all_sync_send!(BinaryHeap::::new(), iter, drain, into_iter); all_sync_send!(BTreeMap::::new(), iter, iter_mut, into_iter, keys, values); is_sync_send!(BTreeMap::::new(), range((Included(&0), Included(&9)))); is_sync_send!(BTreeMap::::new(), range_mut((Included(&0), Included(&9)))); all_sync_send!(BTreeSet::::new(), iter, into_iter); is_sync_send!(BTreeSet::::new(), range((Included(&0), Included(&9)))); is_sync_send!(BTreeSet::::new(), difference(&BTreeSet::::new())); is_sync_send!(BTreeSet::::new(), symmetric_difference(&BTreeSet::::new())); is_sync_send!(BTreeSet::::new(), intersection(&BTreeSet::::new())); is_sync_send!(BTreeSet::::new(), union(&BTreeSet::::new())); all_sync_send!(HashMap::::new(), iter, iter_mut, drain, into_iter, keys, values); is_sync_send!(HashMap::::new(), entry(0)); all_sync_send!(HashSet::::new(), iter, drain, into_iter); is_sync_send!(HashSet::::new(), difference(&HashSet::::new())); is_sync_send!(HashSet::::new(), symmetric_difference(&HashSet::::new())); is_sync_send!(HashSet::::new(), intersection(&HashSet::::new())); is_sync_send!(HashSet::::new(), union(&HashSet::::new())); all_sync_send!(LinkedList::::new(), iter, iter_mut, 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(..)); is_sync_send!(String::new(), drain(..)); }