macro_rules! change_key_methods {
() => {
fn change_key<K2: Eq + std::hash::Hash + Clone + 'static>(
&self,
key_selector: impl Fn(&T) -> K2 + 'static,
) -> std::rc::Rc<dyn ferroui_system::IObservable<crate::cache::ChangeSet<T, K2>>> {
ferroui_reactive::ObservableExt::select(&self.change_sets(), move |updates: crate::cache::ChangeSet<T, K>| {
updates
.iter()
.map(|u| crate::cache::Change::with_previous(u.reason(), key_selector(u.current()), u.current().clone(), u.previous().cloned(), None, None))
.collect::<crate::cache::ChangeSet<T, K2>>()
})
}
fn change_key_with_key<K2: Eq + std::hash::Hash + Clone + 'static>(
&self,
key_selector: impl Fn(&K, &T) -> K2 + 'static,
) -> std::rc::Rc<dyn ferroui_system::IObservable<crate::cache::ChangeSet<T, K2>>> {
ferroui_reactive::ObservableExt::select(&self.change_sets(), move |updates: crate::cache::ChangeSet<T, K>| {
updates
.iter()
.map(|u| crate::cache::Change::with_previous(u.reason(), key_selector(u.key(), u.current()), u.current().clone(), u.previous().cloned(), None, None))
.collect::<crate::cache::ChangeSet<T, K2>>()
})
}
};
}
pub(crate) use change_key_methods;