diff options
Diffstat (limited to '')
| -rw-r--r-- | futures/src/lib.rs | 4 | ||||
| -rw-r--r-- | futures/src/maybe.rs | 35 | ||||
| -rw-r--r-- | futures/src/maybe_send.rs | 21 | 
3 files changed, 37 insertions, 23 deletions
| diff --git a/futures/src/lib.rs b/futures/src/lib.rs index d54ba18a..b0acb76f 100644 --- a/futures/src/lib.rs +++ b/futures/src/lib.rs @@ -15,7 +15,7 @@  pub use futures;  pub use iced_core as core; -mod maybe_send; +mod maybe;  mod runtime;  pub mod backend; @@ -25,7 +25,7 @@ pub mod keyboard;  pub mod subscription;  pub use executor::Executor; -pub use maybe_send::MaybeSend; +pub use maybe::{MaybeSend, MaybeSync};  pub use platform::*;  pub use runtime::Runtime;  pub use subscription::Subscription; 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}; diff --git a/futures/src/maybe_send.rs b/futures/src/maybe_send.rs deleted file mode 100644 index a6670f0e..00000000 --- a/futures/src/maybe_send.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[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; | 
