From 0c628a2a4437af6af15f0d6a3eb159dc02c9755b Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 24 Apr 2024 13:26:27 +0200 Subject: [PATCH] bin: Use associated types in views --- bin/commands/inbox/select.rs | 4 +++- bin/commands/inbox/select/ui.rs | 21 +++++++++++++++------ bin/commands/issue/select.rs | 6 ++++-- bin/commands/issue/select/ui.rs | 21 +++++++++++++++------ bin/commands/patch/select.rs | 6 ++++-- bin/commands/patch/select/ui.rs | 21 +++++++++++++++------ 6 files changed, 56 insertions(+), 23 deletions(-) diff --git a/bin/commands/inbox/select.rs b/bin/commands/inbox/select.rs index feb11183..9d6906b8 100644 --- a/bin/commands/inbox/select.rs +++ b/bin/commands/inbox/select.rs @@ -210,7 +210,9 @@ pub enum Action { ScrollHelp { progress: usize }, } -impl store::State for State { +impl store::State for State { + type Action = Action; + fn tick(&self) {} fn handle_action(&mut self, action: Action) -> Option> { diff --git a/bin/commands/inbox/select/ui.rs b/bin/commands/inbox/select/ui.rs index 22e0649c..e7dc91d3 100644 --- a/bin/commands/inbox/select/ui.rs +++ b/bin/commands/inbox/select/ui.rs @@ -119,10 +119,13 @@ pub struct BrowsePage<'a, B> { shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for BrowsePage<'a, B> +impl<'a: 'static, B> View for BrowsePage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self { let props = BrowsePageProps::from(state); let name = match state.mode.repository() { @@ -327,7 +330,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> { } } -impl<'a: 'static, B> Widget for BrowsePage<'a, B> +impl<'a: 'static, B> Widget for BrowsePage<'a, B> where B: Backend + 'a, { @@ -396,7 +399,10 @@ pub struct Search { input: BoxedWidget, } -impl View for Search { +impl View for Search { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -453,7 +459,7 @@ impl View for Search { } } -impl Widget for Search +impl Widget for Search where B: Backend, { @@ -501,10 +507,13 @@ where shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for HelpPage<'a, B> +impl<'a: 'static, B> View for HelpPage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -604,7 +613,7 @@ where } } -impl<'a: 'static, B> Widget for HelpPage<'a, B> +impl<'a: 'static, B> Widget for HelpPage<'a, B> where B: Backend + 'a, { diff --git a/bin/commands/issue/select.rs b/bin/commands/issue/select.rs index 52425210..86694ce0 100644 --- a/bin/commands/issue/select.rs +++ b/bin/commands/issue/select.rs @@ -129,8 +129,8 @@ pub enum Action { ScrollHelp { progress: usize }, } -impl store::State for State { - fn tick(&self) {} +impl store::State for State { + type Action = Action; fn handle_action(&mut self, action: Action) -> Option> { match action { @@ -185,6 +185,8 @@ impl store::State for State { } } } + + fn tick(&self) {} } impl App { diff --git a/bin/commands/issue/select/ui.rs b/bin/commands/issue/select/ui.rs index 82163689..1389dc7c 100644 --- a/bin/commands/issue/select/ui.rs +++ b/bin/commands/issue/select/ui.rs @@ -133,10 +133,13 @@ pub struct BrowsePage<'a, B> { shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for BrowsePage<'a, B> +impl<'a: 'static, B> View for BrowsePage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self { let props = BrowsePageProps::from(state); @@ -346,7 +349,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> { } } -impl<'a: 'static, B> Widget for BrowsePage<'a, B> +impl<'a: 'static, B> Widget for BrowsePage<'a, B> where B: Backend + 'a, { @@ -415,7 +418,10 @@ pub struct Search { input: BoxedWidget, } -impl View for Search { +impl View for Search { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -472,7 +478,7 @@ impl View for Search { } } -impl Widget for Search +impl Widget for Search where B: Backend, { @@ -520,10 +526,13 @@ where shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for HelpPage<'a, B> +impl<'a: 'static, B> View for HelpPage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -623,7 +632,7 @@ where } } -impl<'a: 'static, B> Widget for HelpPage<'a, B> +impl<'a: 'static, B> Widget for HelpPage<'a, B> where B: Backend + 'a, { diff --git a/bin/commands/patch/select.rs b/bin/commands/patch/select.rs index fbd65558..b8adad8d 100644 --- a/bin/commands/patch/select.rs +++ b/bin/commands/patch/select.rs @@ -134,8 +134,8 @@ pub enum Action { ScrollHelp { progress: usize }, } -impl store::State for State { - fn tick(&self) {} +impl store::State for State { + type Action = Action; fn handle_action(&mut self, action: Action) -> Option> { match action { @@ -190,6 +190,8 @@ impl store::State for State { } } } + + fn tick(&self) {} } impl App { diff --git a/bin/commands/patch/select/ui.rs b/bin/commands/patch/select/ui.rs index 6f41c3eb..05300ef5 100644 --- a/bin/commands/patch/select/ui.rs +++ b/bin/commands/patch/select/ui.rs @@ -134,10 +134,13 @@ pub struct BrowsePage<'a, B> { shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for BrowsePage<'a, B> +impl<'a: 'static, B> View for BrowsePage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self { let props = BrowsePageProps::from(state); @@ -374,7 +377,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> { } } -impl<'a: 'static, B> Widget for BrowsePage<'a, B> +impl<'a: 'static, B> Widget for BrowsePage<'a, B> where B: Backend + 'a, { @@ -443,7 +446,10 @@ pub struct Search { input: BoxedWidget, } -impl View for Search { +impl View for Search { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -500,7 +506,7 @@ impl View for Search { } } -impl Widget for Search +impl Widget for Search where B: Backend, { @@ -548,10 +554,13 @@ where shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for HelpPage<'a, B> +impl<'a: 'static, B> View for HelpPage<'a, B> where B: Backend + 'a, { + type Action = Action; + type State = State; + fn new(state: &State, action_tx: UnboundedSender) -> Self where Self: Sized, @@ -651,7 +660,7 @@ where } } -impl<'a: 'static, B> Widget for HelpPage<'a, B> +impl<'a: 'static, B> Widget for HelpPage<'a, B> where B: Backend + 'a, {