Merge pull request #2000 from ids1024/perform
Fix `Command<T>::perform` to return a `Command<T>`
This commit is contained in:
commit
0770e7eaf8
2 changed files with 4 additions and 7 deletions
|
|
@ -298,10 +298,7 @@ fn numeric_input(
|
|||
) -> Element<'_, Option<u32>> {
|
||||
text_input(
|
||||
placeholder,
|
||||
&value
|
||||
.as_ref()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_else(String::new),
|
||||
&value.as_ref().map(ToString::to_string).unwrap_or_default(),
|
||||
)
|
||||
.on_input(move |text| {
|
||||
if text.is_empty() {
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ impl<T> Command<T> {
|
|||
|
||||
/// Creates a [`Command`] that performs the action of the given future.
|
||||
pub fn perform<A>(
|
||||
future: impl Future<Output = T> + 'static + MaybeSend,
|
||||
f: impl FnOnce(T) -> A + 'static + MaybeSend,
|
||||
) -> Command<A> {
|
||||
future: impl Future<Output = A> + 'static + MaybeSend,
|
||||
f: impl FnOnce(A) -> T + 'static + MaybeSend,
|
||||
) -> Command<T> {
|
||||
use iced_futures::futures::FutureExt;
|
||||
|
||||
Command::single(Action::Future(Box::pin(future.map(f))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue