From 5dab5a327ef643ee38ac3e42ab35212fff445631 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 28 Jan 2022 17:35:47 +0700 Subject: Introduce `MaybeSend` trait in `iced_futures` It allows to clean up all the `trait_aliases` modules! --- futures/src/maybe_send.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 futures/src/maybe_send.rs (limited to 'futures/src/maybe_send.rs') diff --git a/futures/src/maybe_send.rs b/futures/src/maybe_send.rs new file mode 100644 index 00000000..a6670f0e --- /dev/null +++ b/futures/src/maybe_send.rs @@ -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 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 MaybeSend for T {} +} + +pub use platform::MaybeSend; -- cgit