Skip to content

Commit

Permalink
Update update.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiznokes committed Nov 10, 2023
1 parent b9c397f commit 4a14418
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions data/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Update {
}

/*
fn update2(nodes: &mut Nodes, node_id: &Id) -> Result<bool, UpdateError> {
fn update2(nodes: &mut Nodes, node_id: &Id, updated: &mut HashSet<Id> ) -> Result<bool, UpdateError> {
let Some(node) = nodes.get_mut(node_id) else {
return Err(UpdateError::NodeNotFound);
Expand All @@ -42,15 +42,35 @@ impl Update {
}
for id in &node.inputs {
if !Self::update2(nodes, id)? {
if !Self::update2(nodes, id, updated)? {
return Ok(false);
}
}
if updated.contains(&node_id) {
return Ok(true)

Check failure on line 51 in data/src/update.rs

View workflow job for this annotation

GitHub Actions / Format + Clippy (nightly)

Diff in /home/runner/work/fan-control-rs/fan-control-rs/data/src/update.rs
}
let mut input_values = Vec::new();
for id in &node.inputs {
match nodes.get(id) {
Some(input_node) => match input_node.value {
Some(value) => input_values.push(value),
None => return Err(UpdateError::ValueIsNone),
},
None => return Err(UpdateError::NodeNotFound),
}
}
node.update(&input_values)?;
updated.insert(node.id);
return Ok(true);

Check failure on line 70 in data/src/update.rs

View workflow job for this annotation

GitHub Actions / Format + Clippy (nightly)

Diff in /home/runner/work/fan-control-rs/fan-control-rs/data/src/update.rs
}
*/


pub fn graph(&mut self, nodes: &mut Nodes, root_nodes: &RootNodes) -> Result<(), UpdateError> {
let mut to_update: Vec<Id> = Vec::new();
Expand Down

0 comments on commit 4a14418

Please sign in to comment.