From 6a5efb10528696454afbf231c098e16812efb1cf Mon Sep 17 00:00:00 2001 From: Thomas <48214567+ThomasFrans@users.noreply.github.com> Date: Wed, 19 Oct 2022 22:02:39 +0200 Subject: [PATCH] Fix `Clone` impl marked todo on Pagination - Fixed a manual implementation of Clone on Pagination (needed extra trait bounds to be derivable) - Made clippy happy :) --- src/ui/layout.rs | 2 +- src/ui/listview.rs | 4 ++-- src/ui/pagination.rs | 15 ++------------- src/ui/search_results.rs | 2 +- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/ui/layout.rs b/src/ui/layout.rs index a026f4c..a215ea1 100644 --- a/src/ui/layout.rs +++ b/src/ui/layout.rs @@ -82,7 +82,7 @@ impl Layout { } pub fn screen, T: IntoBoxedViewExt>(mut self, id: S, view: T) -> Self { - (&mut self).add_screen(id, view); + self.add_screen(id, view); self } diff --git a/src/ui/listview.rs b/src/ui/listview.rs index db9992f..555002e 100644 --- a/src/ui/listview.rs +++ b/src/ui/listview.rs @@ -57,7 +57,7 @@ impl Scroller for ListView { } } -impl ListView { +impl ListView { pub fn new(content: Arc>>, queue: Arc, library: Arc) -> Self { let result = Self { content, @@ -178,7 +178,7 @@ impl ListView { } } -impl View for ListView { +impl View for ListView { fn draw(&self, printer: &Printer<'_, '_>) { let content = self.content.read().unwrap(); diff --git a/src/ui/pagination.rs b/src/ui/pagination.rs index 6367059..ce05bbb 100644 --- a/src/ui/pagination.rs +++ b/src/ui/pagination.rs @@ -92,6 +92,7 @@ pub type Paginator = Box>>) + Send + Sync>; /// `max_content`: The maximum amount of items /// `callback`: TODO: document /// `busy`: TODO: document +#[derive(Clone)] pub struct Pagination { loaded_content: Arc>, max_content: Arc>>, @@ -110,19 +111,7 @@ impl Default for Pagination { } } -// TODO: figure out why deriving Clone doesn't work -impl Clone for Pagination { - fn clone(&self) -> Self { - Pagination { - loaded_content: self.loaded_content.clone(), - max_content: self.max_content.clone(), - callback: self.callback.clone(), - busy: self.busy.clone(), - } - } -} - -impl Pagination { +impl Pagination { pub fn clear(&mut self) { *self.max_content.write().unwrap() = None; *self.callback.write().unwrap() = None; diff --git a/src/ui/search_results.rs b/src/ui/search_results.rs index c88d363..c2f13ec 100644 --- a/src/ui/search_results.rs +++ b/src/ui/search_results.rs @@ -348,7 +348,7 @@ impl SearchResultsView { 0 } - fn perform_search( + fn perform_search( &self, handler: SearchHandler, results: &Arc>>,