Essentially:
I have a generic implementation of a for a trait that takes a PrimaryID by reference from an object.
What im struggling with is taking that id by reference from an iterable of that object
type PrimaryId: Serialize + DeserializeOwned + Hash + Eq + Display + Clone + Send + Sync + 'static;
fn get_primary_id(&self) ->Self::PrimaryId;
}
pub trait ExtractPrimaryIds<T: GetPrimaryId> {
fn primary_ids(&self) -> Vec<&T::PrimaryId>;
}
impl<'a, T, I> ExtractPrimaryIds<T> for &'a I
where
T: GetPrimaryId<PrimaryId = &'a <T as GetPrimaryId>::PrimaryId> + 'a,
&'a I: IntoIterator<Item = &'a T>,
{
fn primary_ids(&self) -> Vec<&'a T::PrimaryId> {
self.into_iter()
.map(|item| item.get_primary_id())
.collect_vec()
}
}```