Introduce MaybeSend trait in iced_futures

It allows to clean up all the `trait_aliases` modules!
This commit is contained in:
Héctor Ramón Jiménez 2022-01-28 17:35:47 +07:00
parent 83c649b574
commit 5dab5a327e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
6 changed files with 49 additions and 150 deletions

21
futures/src/maybe_send.rs Normal file
View file

@ -0,0 +1,21 @@
#[cfg(not(target_arch = "wasm32"))]
mod platform {
/// An extension trait that enforces `Send` only on native platforms.
///
/// Useful to write cross-platform async code!
pub trait MaybeSend: Send {}
impl<T> MaybeSend for T where T: Send {}
}
#[cfg(target_arch = "wasm32")]
mod platform {
/// An extension trait that enforces `Send` only on native platforms.
///
/// Useful to write cross-platform async code!
pub trait MaybeSend {}
impl<T> MaybeSend for T {}
}
pub use platform::MaybeSend;