From 92de3c80d482eae5ba657d0bd2a80ddfc5571bae Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 24 Apr 2024 14:16:15 +0200 Subject: [PATCH] patch: Remove unnecessary generic backend parameter --- bin/commands/patch/select.rs | 3 +- bin/commands/patch/select/ui.rs | 53 +++++++++++---------------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/bin/commands/patch/select.rs b/bin/commands/patch/select.rs index b8adad8d..932cc6e6 100644 --- a/bin/commands/patch/select.rs +++ b/bin/commands/patch/select.rs @@ -15,7 +15,6 @@ use tui::cob::patch; use tui::store; use tui::task; use tui::task::Interrupted; -use tui::terminal::Backend; use tui::ui::items::{Filter, PatchItem, PatchItemFilter}; use tui::ui::widget::Properties; use tui::ui::widget::View; @@ -205,7 +204,7 @@ impl App { let (frontend, action_tx, action_rx) = Frontend::::new(); let state = State::try_from(&self.context)?; - let window: Window = Window::new(&state, action_tx.clone()) + let window: Window = Window::new(&state, action_tx.clone()) .page( Page::Browse, BrowsePage::new(&state, action_tx.clone()).to_boxed(), diff --git a/bin/commands/patch/select/ui.rs b/bin/commands/patch/select/ui.rs index 05300ef5..7c1eaf5d 100644 --- a/bin/commands/patch/select/ui.rs +++ b/bin/commands/patch/select/ui.rs @@ -8,7 +8,6 @@ use tokio::sync::mpsc::UnboundedSender; use termion::event::Key; -use ratatui::backend::Backend; use ratatui::layout::{Constraint, Layout, Rect}; use ratatui::style::Stylize; use ratatui::text::{Line, Span, Text}; @@ -36,7 +35,7 @@ use crate::tui_patch::common::PatchOperation; use super::{Action, State}; -type BoxedWidget = widget::BoxedWidget; +type BoxedWidget = widget::BoxedWidget; #[derive(Clone)] pub struct BrowsePageProps<'a> { @@ -121,23 +120,20 @@ impl<'a> From<&State> for BrowsePageProps<'a> { impl<'a: 'static> Properties for BrowsePageProps<'a> {} -pub struct BrowsePage<'a, B> { +pub struct BrowsePage<'a> { /// Internal base base: BaseView, /// Internal props props: BrowsePageProps<'a>, /// Notifications widget - patches: BoxedWidget, + patches: BoxedWidget, /// Search widget - search: BoxedWidget, + search: BoxedWidget, /// Shortcut widget - shortcuts: BoxedWidget, + shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for BrowsePage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> View for BrowsePage<'a> { type Action = Action; type State = State; @@ -290,7 +286,7 @@ where } } -impl<'a, B: Backend> BrowsePage<'a, B> { +impl<'a> BrowsePage<'a> { fn build_footer(props: &BrowsePageProps<'a>, selected: Option) -> Vec> { let filter = PatchItemFilter::from_str(&props.search).unwrap_or_default(); @@ -377,10 +373,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> { } } -impl<'a: 'static, B> Widget for BrowsePage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> Widget for BrowsePage<'a> { fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option>) { let props = props .and_then(BrowsePageProps::from_boxed_any) @@ -437,16 +430,16 @@ pub struct SearchProps {} impl Properties for SearchProps {} -pub struct Search { +pub struct Search { /// Internal base base: BaseView, /// Internal props _props: SearchProps, /// Search input field - input: BoxedWidget, + input: BoxedWidget, } -impl View for Search { +impl View for Search { type Action = Action; type State = State; @@ -506,10 +499,7 @@ impl View for Search { } } -impl Widget for Search -where - B: Backend, -{ +impl Widget for Search { fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option>) { let layout = Layout::horizontal(Constraint::from_mins([0])) .horizontal_margin(1) @@ -540,24 +530,18 @@ impl<'a> From<&State> for HelpPageProps<'a> { impl<'a> Properties for HelpPageProps<'a> {} -pub struct HelpPage<'a, B> -where - B: Backend, -{ +pub struct HelpPage<'a> { /// Internal base base: BaseView, /// Internal props props: HelpPageProps<'a>, /// Content widget - content: BoxedWidget, + content: BoxedWidget, /// Shortcut widget - shortcuts: BoxedWidget, + shortcuts: BoxedWidget, } -impl<'a: 'static, B> View for HelpPage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> View for HelpPage<'a> { type Action = Action; type State = State; @@ -660,10 +644,7 @@ where } } -impl<'a: 'static, B> Widget for HelpPage<'a, B> -where - B: Backend + 'a, -{ +impl<'a: 'static> Widget for HelpPage<'a> { fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option>) { let props = props .and_then(HelpPageProps::from_boxed_any)