add type coercion helper to ListItem objects
This commit is contained in:
@@ -150,6 +150,10 @@ impl ListItem for Album {
|
||||
}
|
||||
}
|
||||
|
||||
fn as_listitem(&self) -> Box<ListItem> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn display_left(&self) -> String {
|
||||
format!("{}", self)
|
||||
}
|
||||
|
||||
@@ -139,6 +139,10 @@ impl ListItem for Artist {
|
||||
}
|
||||
}
|
||||
|
||||
fn as_listitem(&self) -> Box<ListItem> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn display_left(&self) -> String {
|
||||
format!("{}", self)
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@ impl ListItem for Playlist {
|
||||
}
|
||||
}
|
||||
|
||||
fn as_listitem(&self) -> Box<ListItem> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn display_left(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
@@ -151,6 +151,10 @@ impl ListItem for Track {
|
||||
current.map(|t| t.id == self.id).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn as_listitem(&self) -> Box<ListItem> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn display_left(&self) -> String {
|
||||
format!("{}", self)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ pub trait ListItem: Sync + Send + 'static {
|
||||
fn artist(&self) -> Option<Artist> {
|
||||
None
|
||||
}
|
||||
|
||||
fn as_listitem(&self) -> Box<ListItem>;
|
||||
}
|
||||
|
||||
pub trait ViewExt: View {
|
||||
|
||||
Reference in New Issue
Block a user