Use structs not enums for Synchronicity types
This commit is contained in:
parent
5998bbe116
commit
1ac8f4ead4
@ -36,7 +36,7 @@ pub trait Synchronicity: 'static {
|
|||||||
fn make_update_result<'a>() -> Self::UpdateResult<'a>;
|
fn make_update_result<'a>() -> Self::UpdateResult<'a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Synchronous {}
|
pub struct Synchronous;
|
||||||
|
|
||||||
impl Synchronicity for Synchronous {
|
impl Synchronicity for Synchronous {
|
||||||
type UpdateFn = Box<dyn Fn(&mut Box<dyn Any>) -> ()>;
|
type UpdateFn = Box<dyn Fn(&mut Box<dyn Any>) -> ()>;
|
||||||
@ -53,7 +53,7 @@ impl Synchronicity for Synchronous {
|
|||||||
fn make_update_result<'a>() -> Self::UpdateResult<'a> {}
|
fn make_update_result<'a>() -> Self::UpdateResult<'a> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Asynchronous {}
|
pub struct Asynchronous;
|
||||||
|
|
||||||
impl Synchronicity for Asynchronous {
|
impl Synchronicity for Asynchronous {
|
||||||
type UpdateFn =
|
type UpdateFn =
|
||||||
@ -480,7 +480,7 @@ impl<V: Clone + 'static, S: Synchronicity> Node<V, S> for ConstNode<V, S> {
|
|||||||
|
|
||||||
fn visit_inputs(&self, _visitor: &mut dyn FnMut(NodeIndex<u32>) -> ()) {}
|
fn visit_inputs(&self, _visitor: &mut dyn FnMut(NodeIndex<u32>) -> ()) {}
|
||||||
|
|
||||||
fn update(&mut self) -> <S as Synchronicity>::UpdateResult<'_> {
|
fn update(&mut self) -> S::UpdateResult<'_> {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ impl<R: Rule, S: Synchronicity> Node<R::Output, S> for RuleNode<R, R::Output, S>
|
|||||||
self.rule.visit_inputs(&mut InputIndexVisitor(visitor));
|
self.rule.visit_inputs(&mut InputIndexVisitor(visitor));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self) -> <S as Synchronicity>::UpdateResult<'_> {
|
fn update(&mut self) -> S::UpdateResult<'_> {
|
||||||
let new_value = self.rule.evaluate();
|
let new_value = self.rule.evaluate();
|
||||||
self.valid = true;
|
self.valid = true;
|
||||||
*self.value.borrow_mut() = Some(new_value);
|
*self.value.borrow_mut() = Some(new_value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user