Skip to content

Commit

Permalink
Merge pull request #2000 from ids1024/perform
Browse files Browse the repository at this point in the history
Fix `Command<T>::perform` to return a `Command<T>`
  • Loading branch information
hecrj authored Oct 18, 2023
2 parents bc9bb28 + 54e6d2b commit 0770e7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions examples/screenshot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit 0770e7e

Please sign in to comment.