#[cfg(not(all(feature = "browser", target_family = "wasm")))]
pub trait MaybeSend: Send {}
#[cfg(not(all(feature = "browser", target_family = "wasm")))]
impl<T: Send + ?Sized> MaybeSend for T {}
#[cfg(all(feature = "browser", target_family = "wasm"))]
pub trait MaybeSend {}
#[cfg(all(feature = "browser", target_family = "wasm"))]
impl<T: ?Sized> MaybeSend for T {}
#[cfg(not(all(feature = "browser", target_family = "wasm")))]
pub trait MaybeSendSync: Send + Sync {}
#[cfg(not(all(feature = "browser", target_family = "wasm")))]
impl<T: Send + Sync + ?Sized> MaybeSendSync for T {}
#[cfg(all(feature = "browser", target_family = "wasm"))]
pub trait MaybeSendSync {}
#[cfg(all(feature = "browser", target_family = "wasm"))]
impl<T: ?Sized> MaybeSendSync for T {}
#[cfg(not(all(feature = "browser", target_family = "wasm")))]
#[macro_export]
macro_rules! maybe_send {
(dyn $($object:tt)+) => { dyn $($object)+ + ::core::marker::Send };
}
#[cfg(all(feature = "browser", target_family = "wasm"))]
#[macro_export]
macro_rules! maybe_send {
(dyn $($object:tt)+) => { dyn $($object)+ };
}
#[cfg(not(all(feature = "browser", target_family = "wasm")))]
#[macro_export]
macro_rules! maybe_send_sync {
(dyn $($object:tt)+) => { dyn $($object)+ + ::core::marker::Send + ::core::marker::Sync };
}
#[cfg(all(feature = "browser", target_family = "wasm"))]
#[macro_export]
macro_rules! maybe_send_sync {
(dyn $($object:tt)+) => { dyn $($object)+ };
}
#[cfg(all(test, not(target_family = "wasm")))]
mod tests {
use std::future::Future;
use std::pin::Pin;
fn is_send<T: Send + ?Sized>() {}
fn is_send_sync<T: Send + Sync + ?Sized>() {}
#[test]
fn test_native_trait_objects_carry_the_native_bounds() {
is_send::<maybe_send!(dyn Future<Output = ()> + 'static)>();
is_send_sync::<maybe_send_sync!(dyn std::error::Error)>();
is_send::<Pin<Box<maybe_send!(dyn Future<Output = u8>)>>>();
}
}