From 90afd1db8df17a7afa06b521ccd52455eced9277 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 28 Jan 2022 21:45:30 +0700 Subject: Use `MaybeSend` in `perform` and `map` for `Command` --- native/src/clipboard.rs | 7 ++++++- native/src/command.rs | 8 +++++--- native/src/command/action.rs | 7 ++++++- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'native') diff --git a/native/src/clipboard.rs b/native/src/clipboard.rs index 60703c31..c9105bc0 100644 --- a/native/src/clipboard.rs +++ b/native/src/clipboard.rs @@ -1,4 +1,6 @@ //! Access the clipboard. +use iced_futures::MaybeSend; + use std::fmt; /// A buffer for short-term storage and transfer within and between @@ -36,7 +38,10 @@ pub enum Action { impl Action { /// Maps the output of a clipboard [`Action`] using the provided closure. - pub fn map(self, f: impl Fn(T) -> A + 'static + Send + Sync) -> Action + pub fn map( + self, + f: impl Fn(T) -> A + 'static + MaybeSend + Sync, + ) -> Action where T: 'static, { diff --git a/native/src/command.rs b/native/src/command.rs index 6fe518d7..89d0f045 100644 --- a/native/src/command.rs +++ b/native/src/command.rs @@ -3,6 +3,8 @@ mod action; pub use action::Action; +use iced_futures::MaybeSend; + use std::fmt; use std::future::Future; @@ -24,8 +26,8 @@ impl Command { /// Creates a [`Command`] that performs the action of the given future. pub fn perform( - future: impl Future + 'static + Send, - f: impl Fn(T) -> A + 'static + Send, + future: impl Future + 'static + MaybeSend, + f: impl Fn(T) -> A + 'static + MaybeSend, ) -> Command { use iced_futures::futures::FutureExt; @@ -45,7 +47,7 @@ impl Command { /// Applies a transformation to the result of a [`Command`]. pub fn map( self, - f: impl Fn(T) -> A + 'static + Send + Sync + Clone, + f: impl Fn(T) -> A + 'static + MaybeSend + Sync + Clone, ) -> Command where T: 'static, diff --git a/native/src/command/action.rs b/native/src/command/action.rs index 77be1b59..5c7509c8 100644 --- a/native/src/command/action.rs +++ b/native/src/command/action.rs @@ -1,6 +1,8 @@ use crate::clipboard; use crate::window; +use iced_futures::MaybeSend; + use std::fmt; /// An action that a [`Command`] can perform. @@ -19,7 +21,10 @@ pub enum Action { impl Action { /// Applies a transformation to the result of a [`Command`]. - pub fn map(self, f: impl Fn(T) -> A + 'static + Send + Sync) -> Action + pub fn map( + self, + f: impl Fn(T) -> A + 'static + MaybeSend + Sync, + ) -> Action where T: 'static, { -- cgit