summaryrefslogtreecommitdiffstats
path: root/core/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-15 01:30:24 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-15 01:30:24 +0200
commit515772c9f8eeaa318bad52fd04caba4da69b075e (patch)
tree0f5998b907c6fd14a2ad6b916e64b77dbf78f1e1 /core/src/widget
parentcfd2e7b116e49b295b3bb484a3f477a9f356d493 (diff)
downloadiced-515772c9f8eeaa318bad52fd04caba4da69b075e.tar.gz
iced-515772c9f8eeaa318bad52fd04caba4da69b075e.tar.bz2
iced-515772c9f8eeaa318bad52fd04caba4da69b075e.zip
Rename `operation::chain` to `then`
... and make `focus_*` operations generic over the output type.
Diffstat (limited to 'core/src/widget')
-rw-r--r--core/src/widget/operation.rs4
-rw-r--r--core/src/widget/operation/focusable.rs14
2 files changed, 12 insertions, 6 deletions
diff --git a/core/src/widget/operation.rs b/core/src/widget/operation.rs
index 741e1a5f..4ee4b4a7 100644
--- a/core/src/widget/operation.rs
+++ b/core/src/widget/operation.rs
@@ -295,7 +295,7 @@ where
/// Chains the output of an [`Operation`] with the provided function to
/// build a new [`Operation`].
-pub fn chain<A, B, O>(
+pub fn then<A, B, O>(
operation: impl Operation<A> + 'static,
f: fn(A) -> O,
) -> impl Operation<B>
@@ -361,7 +361,7 @@ where
Outcome::Chain(Box::new((self.next)(value)))
}
Outcome::Chain(operation) => {
- Outcome::Chain(Box::new(chain(operation, self.next)))
+ Outcome::Chain(Box::new(then(operation, self.next)))
}
}
}
diff --git a/core/src/widget/operation/focusable.rs b/core/src/widget/operation/focusable.rs
index 0a6f2e96..867c682e 100644
--- a/core/src/widget/operation/focusable.rs
+++ b/core/src/widget/operation/focusable.rs
@@ -94,7 +94,10 @@ pub fn count() -> impl Operation<Count> {
/// Produces an [`Operation`] that searches for the current focused widget, and
/// - if found, focuses the previous focusable widget.
/// - if not found, focuses the last focusable widget.
-pub fn focus_previous() -> impl Operation {
+pub fn focus_previous<T>() -> impl Operation<T>
+where
+ T: Send + 'static,
+{
struct FocusPrevious {
count: Count,
current: usize,
@@ -128,13 +131,16 @@ pub fn focus_previous() -> impl Operation {
}
}
- operation::chain(count(), |count| FocusPrevious { count, current: 0 })
+ operation::then(count(), |count| FocusPrevious { count, current: 0 })
}
/// Produces an [`Operation`] that searches for the current focused widget, and
/// - if found, focuses the next focusable widget.
/// - if not found, focuses the first focusable widget.
-pub fn focus_next() -> impl Operation {
+pub fn focus_next<T>() -> impl Operation<T>
+where
+ T: Send + 'static,
+{
struct FocusNext {
count: Count,
current: usize,
@@ -162,7 +168,7 @@ pub fn focus_next() -> impl Operation {
}
}
- operation::chain(count(), |count| FocusNext { count, current: 0 })
+ operation::then(count(), |count| FocusNext { count, current: 0 })
}
/// Produces an [`Operation`] that searches for the current focused widget