summaryrefslogtreecommitdiffstats
path: root/futures/src/maybe_send.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-28 17:35:47 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-28 21:37:17 +0700
commit5dab5a327ef643ee38ac3e42ab35212fff445631 (patch)
treef3b9f2e64a538f250e4785677f7985bd11e4ed3b /futures/src/maybe_send.rs
parent83c649b574d90667d23c8430baaebcd0ef933055 (diff)
downloadiced-5dab5a327ef643ee38ac3e42ab35212fff445631.tar.gz
iced-5dab5a327ef643ee38ac3e42ab35212fff445631.tar.bz2
iced-5dab5a327ef643ee38ac3e42ab35212fff445631.zip
Introduce `MaybeSend` trait in `iced_futures`
It allows to clean up all the `trait_aliases` modules!
Diffstat (limited to '')
-rw-r--r--futures/src/maybe_send.rs21
1 files changed, 21 insertions, 0 deletions
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<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;