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 :)
This commit is contained in:
@@ -82,7 +82,7 @@ impl Layout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn screen<S: Into<String>, T: IntoBoxedViewExt>(mut self, id: S, view: T) -> Self {
|
pub fn screen<S: Into<String>, T: IntoBoxedViewExt>(mut self, id: S, view: T) -> Self {
|
||||||
(&mut self).add_screen(id, view);
|
self.add_screen(id, view);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ impl<I: ListItem> Scroller for ListView<I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: ListItem> ListView<I> {
|
impl<I: ListItem + Clone> ListView<I> {
|
||||||
pub fn new(content: Arc<RwLock<Vec<I>>>, queue: Arc<Queue>, library: Arc<Library>) -> Self {
|
pub fn new(content: Arc<RwLock<Vec<I>>>, queue: Arc<Queue>, library: Arc<Library>) -> Self {
|
||||||
let result = Self {
|
let result = Self {
|
||||||
content,
|
content,
|
||||||
@@ -178,7 +178,7 @@ impl<I: ListItem> ListView<I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: ListItem> View for ListView<I> {
|
impl<I: ListItem + Clone> View for ListView<I> {
|
||||||
fn draw(&self, printer: &Printer<'_, '_>) {
|
fn draw(&self, printer: &Printer<'_, '_>) {
|
||||||
let content = self.content.read().unwrap();
|
let content = self.content.read().unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ pub type Paginator<I> = Box<dyn Fn(Arc<RwLock<Vec<I>>>) + Send + Sync>;
|
|||||||
/// `max_content`: The maximum amount of items
|
/// `max_content`: The maximum amount of items
|
||||||
/// `callback`: TODO: document
|
/// `callback`: TODO: document
|
||||||
/// `busy`: TODO: document
|
/// `busy`: TODO: document
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Pagination<I: ListItem> {
|
pub struct Pagination<I: ListItem> {
|
||||||
loaded_content: Arc<RwLock<usize>>,
|
loaded_content: Arc<RwLock<usize>>,
|
||||||
max_content: Arc<RwLock<Option<usize>>>,
|
max_content: Arc<RwLock<Option<usize>>>,
|
||||||
@@ -110,19 +111,7 @@ impl<I: ListItem> Default for Pagination<I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out why deriving Clone doesn't work
|
impl<I: ListItem + Clone> Pagination<I> {
|
||||||
impl<I: ListItem> Clone for Pagination<I> {
|
|
||||||
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<I: ListItem> Pagination<I> {
|
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
*self.max_content.write().unwrap() = None;
|
*self.max_content.write().unwrap() = None;
|
||||||
*self.callback.write().unwrap() = None;
|
*self.callback.write().unwrap() = None;
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ impl SearchResultsView {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perform_search<I: ListItem>(
|
fn perform_search<I: ListItem + Clone>(
|
||||||
&self,
|
&self,
|
||||||
handler: SearchHandler<I>,
|
handler: SearchHandler<I>,
|
||||||
results: &Arc<RwLock<Vec<I>>>,
|
results: &Arc<RwLock<Vec<I>>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user