Rename operation::chain to then

... and make `focus_*` operations generic over
the output type.
This commit is contained in:
Héctor Ramón Jiménez 2024-08-15 01:30:24 +02:00
parent cfd2e7b116
commit 515772c9f8
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F
2 changed files with 12 additions and 6 deletions

View file

@ -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