Use MaybeSend in perform and map for Command
This commit is contained in:
parent
e730d97f61
commit
90afd1db8d
3 changed files with 17 additions and 5 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
//! Access the clipboard.
|
//! Access the clipboard.
|
||||||
|
use iced_futures::MaybeSend;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// A buffer for short-term storage and transfer within and between
|
/// A buffer for short-term storage and transfer within and between
|
||||||
|
|
@ -36,7 +38,10 @@ pub enum Action<T> {
|
||||||
|
|
||||||
impl<T> Action<T> {
|
impl<T> Action<T> {
|
||||||
/// Maps the output of a clipboard [`Action`] using the provided closure.
|
/// Maps the output of a clipboard [`Action`] using the provided closure.
|
||||||
pub fn map<A>(self, f: impl Fn(T) -> A + 'static + Send + Sync) -> Action<A>
|
pub fn map<A>(
|
||||||
|
self,
|
||||||
|
f: impl Fn(T) -> A + 'static + MaybeSend + Sync,
|
||||||
|
) -> Action<A>
|
||||||
where
|
where
|
||||||
T: 'static,
|
T: 'static,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ mod action;
|
||||||
|
|
||||||
pub use action::Action;
|
pub use action::Action;
|
||||||
|
|
||||||
|
use iced_futures::MaybeSend;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
|
|
@ -24,8 +26,8 @@ impl<T> Command<T> {
|
||||||
|
|
||||||
/// Creates a [`Command`] that performs the action of the given future.
|
/// Creates a [`Command`] that performs the action of the given future.
|
||||||
pub fn perform<A>(
|
pub fn perform<A>(
|
||||||
future: impl Future<Output = T> + 'static + Send,
|
future: impl Future<Output = T> + 'static + MaybeSend,
|
||||||
f: impl Fn(T) -> A + 'static + Send,
|
f: impl Fn(T) -> A + 'static + MaybeSend,
|
||||||
) -> Command<A> {
|
) -> Command<A> {
|
||||||
use iced_futures::futures::FutureExt;
|
use iced_futures::futures::FutureExt;
|
||||||
|
|
||||||
|
|
@ -45,7 +47,7 @@ impl<T> Command<T> {
|
||||||
/// Applies a transformation to the result of a [`Command`].
|
/// Applies a transformation to the result of a [`Command`].
|
||||||
pub fn map<A>(
|
pub fn map<A>(
|
||||||
self,
|
self,
|
||||||
f: impl Fn(T) -> A + 'static + Send + Sync + Clone,
|
f: impl Fn(T) -> A + 'static + MaybeSend + Sync + Clone,
|
||||||
) -> Command<A>
|
) -> Command<A>
|
||||||
where
|
where
|
||||||
T: 'static,
|
T: 'static,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::clipboard;
|
use crate::clipboard;
|
||||||
use crate::window;
|
use crate::window;
|
||||||
|
|
||||||
|
use iced_futures::MaybeSend;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// An action that a [`Command`] can perform.
|
/// An action that a [`Command`] can perform.
|
||||||
|
|
@ -19,7 +21,10 @@ pub enum Action<T> {
|
||||||
|
|
||||||
impl<T> Action<T> {
|
impl<T> Action<T> {
|
||||||
/// Applies a transformation to the result of a [`Command`].
|
/// Applies a transformation to the result of a [`Command`].
|
||||||
pub fn map<A>(self, f: impl Fn(T) -> A + 'static + Send + Sync) -> Action<A>
|
pub fn map<A>(
|
||||||
|
self,
|
||||||
|
f: impl Fn(T) -> A + 'static + MaybeSend + Sync,
|
||||||
|
) -> Action<A>
|
||||||
where
|
where
|
||||||
T: 'static,
|
T: 'static,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue