wip: add use_callback

This commit is contained in:
Jonathan Kelley committed 2022-02-23 09:47:53 -05:00
1 parent 3837899a7e
commit 7a5c403e38
3 files changed
+92 -2

No files matched your search

+22
View File
@@ -146,6 +146,28 @@ impl UseFutureDep for () {
pub trait Dep: 'static + PartialEq + Clone {}
impl<T> Dep for T where T: 'static + PartialEq + Clone {}
impl<A: Dep> UseFutureDep for &A {
type Out = A;
fn out(&self) -> Self::Out {
(*self).clone()
}
fn apply(self, state: &mut Vec<Box<dyn Any>>) -> bool {
match state.get_mut(0).map(|f| f.downcast_mut::<A>()).flatten() {
Some(val) => {
if *val != *self {
*val = self.clone();
return true;
}
}
None => {
state.push(Box::new(self.clone()));
return true;
}
}
false
}
}
macro_rules! impl_dep {
(
$($el:ident=$name:ident,)*