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>> {
|
) -> Element<'_, Option<u32>> {
|
||||||
text_input(
|
text_input(
|
||||||
placeholder,
|
placeholder,
|
||||||
&value
|
&value.as_ref().map(ToString::to_string).unwrap_or_default(),
|
||||||
.as_ref()
|
|
||||||
.map(ToString::to_string)
|
|
||||||
.unwrap_or_else(String::new),
|
|
||||||
)
|
)
|
||||||
.on_input(move |text| {
|
.on_input(move |text| {
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ 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 + MaybeSend,
|
future: impl Future<Output = A> + 'static + MaybeSend,
|
||||||
f: impl FnOnce(T) -> A + 'static + MaybeSend,
|
f: impl FnOnce(A) -> T + 'static + MaybeSend,
|
||||||
) -> Command<A> {
|
) -> Command<T> {
|
||||||
use iced_futures::futures::FutureExt;
|
use iced_futures::futures::FutureExt;
|
||||||
|
|
||||||
Command::single(Action::Future(Box::pin(future.map(f))))
|
Command::single(Action::Future(Box::pin(future.map(f))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue