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/runtime.rs | 56 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'futures/src/runtime.rs') diff --git a/futures/src/runtime.rs b/futures/src/runtime.rs index 96104cd9..2034ed6c 100644 --- a/futures/src/runtime.rs +++ b/futures/src/runtime.rs @@ -1,54 +1,10 @@ //! Run commands and keep track of subscriptions. -use crate::BoxFuture; -use crate::{subscription, Executor, Subscription}; +use crate::subscription; +use crate::{BoxFuture, Executor, MaybeSend, Subscription}; use futures::{channel::mpsc, Sink}; use std::marker::PhantomData; -#[cfg(not(target_arch = "wasm32"))] -mod trait_aliases { - use super::*; - - pub trait RuntimeMessage: Send + 'static {} - - impl RuntimeMessage for T where T: Send + 'static {} - - pub trait RuntimeMessageSender: - Sink + Unpin + Send + Clone + 'static - { - } - - impl RuntimeMessageSender for T where - T: Sink - + Unpin - + Send - + Clone - + 'static - { - } -} - -#[cfg(target_arch = "wasm32")] -mod trait_aliases { - use super::*; - - pub trait RuntimeMessage: 'static {} - - impl RuntimeMessage for T where T: 'static {} - - pub trait RuntimeMessageSender: - Sink + Unpin + Clone + 'static - { - } - - impl RuntimeMessageSender for T where - T: Sink + Unpin + Clone + 'static - { - } -} - -pub use trait_aliases::{RuntimeMessage, RuntimeMessageSender}; - /// A batteries-included runtime of commands and subscriptions. /// /// If you have an [`Executor`], a [`Runtime`] can be leveraged to run any @@ -67,8 +23,12 @@ where Hasher: std::hash::Hasher + Default, Event: Send + Clone + 'static, Executor: self::Executor, - Sender: RuntimeMessageSender, - Message: RuntimeMessage, + Sender: Sink + + Unpin + + MaybeSend + + Clone + + 'static, + Message: MaybeSend + 'static, { /// Creates a new empty [`Runtime`]. /// -- cgit