summaryrefslogtreecommitdiffstats
path: root/native/src/command.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-08-05 22:31:26 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-05 22:31:26 +0200
commitf294c2d16249ce8b7989f8af6332678f53d8fb12 (patch)
treebb8d6f00fe25de9187b1d3b90a88ae95225b7428 /native/src/command.rs
parenta003e797e8a1bb5d365c1db5de6af88e61a47329 (diff)
parentad5bd0970d7106a97d455a164a582ab1d0bff18b (diff)
downloadiced-f294c2d16249ce8b7989f8af6332678f53d8fb12.tar.gz
iced-f294c2d16249ce8b7989f8af6332678f53d8fb12.tar.bz2
iced-f294c2d16249ce8b7989f8af6332678f53d8fb12.zip
Merge pull request #1399 from iced-rs/widget-operations
Widget Operations
Diffstat (limited to 'native/src/command.rs')
-rw-r--r--native/src/command.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/native/src/command.rs b/native/src/command.rs
index 89d0f045..b0b12805 100644
--- a/native/src/command.rs
+++ b/native/src/command.rs
@@ -3,6 +3,8 @@ mod action;
pub use action::Action;
+use crate::widget;
+
use iced_futures::MaybeSend;
use std::fmt;
@@ -24,6 +26,13 @@ impl<T> Command<T> {
Self(iced_futures::Command::single(action))
}
+ /// Creates a [`Command`] that performs a [`widget::Operation`].
+ pub fn widget(operation: impl widget::Operation<T> + 'static) -> Self {
+ Self(iced_futures::Command::single(Action::Widget(
+ widget::Action::new(operation),
+ )))
+ }
+
/// Creates a [`Command`] that performs the action of the given future.
pub fn perform<A>(
future: impl Future<Output = T> + 'static + MaybeSend,
@@ -51,6 +60,7 @@ impl<T> Command<T> {
) -> Command<A>
where
T: 'static,
+ A: 'static,
{
let Command(command) = self;