use std::iter; use impls::impls; use any_vec::{AnyVec, AnyVecMut, IterMut, IterRef, mem}; use any_vec::any_value::AnyValueWrapper; use any_vec::mem::MemBuilder; use any_vec::ops::Drain; use any_vec::ops::Splice; use any_vec::traits::None; const fn is_send(_: &impl Send){} const fn is_sync(_: &impl Sync){} #[test] fn any_vec_heap_send_sync_test() { fn test_negative() { let mut any_vec: AnyVec = AnyVec::new::(); assert!(!impls!(AnyVec: Send)); assert!(!impls!(AnyVec: Sync)); { let iter: IterRef = any_vec.iter(); assert!(!impls!(IterRef: Send)); assert!(!impls!(IterRef: Sync)); drop(iter); } { let iter: IterMut = any_vec.iter_mut(); assert!(!impls!(IterMut: Send)); assert!(!impls!(IterMut: Sync)); drop(iter); } { let vec: AnyVecMut = any_vec.downcast_mut::().unwrap(); assert!(!impls!(AnyVecMut: Send)); assert!(!impls!(AnyVecMut: Sync)); drop(vec); } { let drained: Drain = any_vec.drain(..); assert!(!impls!(AnyVec: Send)); assert!(!impls!(AnyVec: Sync)); drop(drained); } { let drained: Splice>> = any_vec.splice(.., iter::empty::>()); assert!(!impls!(Splice>>: Send)); assert!(!impls!(Splice>>: Sync)); drop(drained); } } fn test_positive() where M::Mem: Sync + Send { let mut any_vec: AnyVec = AnyVec::new::(); is_sync(&any_vec); is_send(&any_vec); is_sync(&any_vec.iter()); is_send(&any_vec.iter()); is_sync(&any_vec.iter_mut()); is_send(&any_vec.iter_mut()); { let mut vec = any_vec.downcast_mut::().unwrap(); is_sync(&vec); is_send(&vec); is_sync(&vec.iter()); is_send(&vec.iter()); is_sync(&vec.iter_mut()); is_send(&vec.iter_mut()); } { let drained = any_vec.drain(..); is_sync(&drained); is_send(&drained); } { let drained = any_vec.splice(.., [AnyValueWrapper::new(String::new())]); is_sync(&drained); is_send(&drained); } } test_positive::(); test_positive::>(); test_negative::(); test_negative::>(); }