pub trait VecProgressEntry {
type Id: 'static + PartialEq;
type Progress: Clone + Default + Ord;
fn id(&self) -> &Self::Id;
fn progress(&self) -> &Self::Progress;
fn progress_mut(&mut self) -> &mut Self::Progress;
fn id_progress(&self) -> (&Self::Id, &Self::Progress) {
(self.id(), self.progress())
}
fn id_progress_owned(&self) -> (Self::Id, Self::Progress)
where Self::Id: Clone {
let (id, progress) = self.id_progress();
(id.clone(), progress.clone())
}
}
pub trait VecProgressEntryData: VecProgressEntry {
type Data;
fn data(&self) -> &Self::Data;
fn data_mut(&mut self) -> &mut Self::Data;
}
impl<ID, Progress> VecProgressEntry for (ID, Progress)
where
ID: 'static + PartialEq,
Progress: Clone + Default + Ord,
{
type Id = ID;
type Progress = Progress;
fn id(&self) -> &Self::Id {
&self.0
}
fn progress(&self) -> &Self::Progress {
&self.1
}
fn progress_mut(&mut self) -> &mut Self::Progress {
&mut self.1
}
}