diff options
author | 2024-06-14 01:57:49 +0200 | |
---|---|---|
committer | 2024-06-14 01:57:49 +0200 | |
commit | 4e7cbbf98ab745351e2fb13a7c85d4ad560c21ee (patch) | |
tree | b1bad3d579ec580c40b9013c389c82376423ce7e /futures/src/maybe.rs | |
parent | 4ab4ffc9cfa6d7bddddb2c4d513e2120244259a1 (diff) | |
download | iced-4e7cbbf98ab745351e2fb13a7c85d4ad560c21ee.tar.gz iced-4e7cbbf98ab745351e2fb13a7c85d4ad560c21ee.tar.bz2 iced-4e7cbbf98ab745351e2fb13a7c85d4ad560c21ee.zip |
Move `Maybe*` traits back to `iced_futures`
Diffstat (limited to 'futures/src/maybe.rs')
-rw-r--r-- | futures/src/maybe.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/futures/src/maybe.rs b/futures/src/maybe.rs new file mode 100644 index 00000000..c6a507c1 --- /dev/null +++ b/futures/src/maybe.rs @@ -0,0 +1,35 @@ +#[cfg(not(target_arch = "wasm32"))] +mod platform { + /// An extension trait that enforces `Send` only on native platforms. + /// + /// Useful for writing cross-platform async code! + pub trait MaybeSend: Send {} + + impl<T> MaybeSend for T where T: Send {} + + /// An extension trait that enforces `Sync` only on native platforms. + /// + /// Useful for writing cross-platform async code! + pub trait MaybeSync: Sync {} + + impl<T> MaybeSync for T where T: Sync {} +} + +#[cfg(target_arch = "wasm32")] +mod platform { + /// An extension trait that enforces `Send` only on native platforms. + /// + /// Useful for writing cross-platform async code! + pub trait MaybeSend {} + + impl<T> MaybeSend for T {} + + /// An extension trait that enforces `Sync` only on native platforms. + /// + /// Useful for writing cross-platform async code! + pub trait MaybeSync {} + + impl<T> MaybeSync for T {} +} + +pub use platform::{MaybeSend, MaybeSync}; |