Skip to content

Commit

Permalink
with value now returns whatever the closure returns
Browse files Browse the repository at this point in the history
  • Loading branch information
togglebyte committed Aug 30, 2024
1 parent 4c064a5 commit 419fa1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion anathema-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ impl<T> RuntimeBuilder<T> {
future_values: FutureValues::empty(),

changes: Changes::empty(),
// tab_indices: TabIndices::new(),
component_registry: self.component_registry,
globals,
document: self.document,
Expand Down
7 changes: 4 additions & 3 deletions anathema-store/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,14 @@ impl<T> Tree<T> {

/// Perform a given operation (`F`) on a mutable reference to a value in the tree
/// while still having mutable access to the rest of the tree.
pub fn with_value_mut<F>(&mut self, value_id: ValueId, f: F)
pub fn with_value_mut<F, V>(&mut self, value_id: ValueId, f: F) -> V
where
F: FnOnce(&[u16], &mut T, &mut Self),
F: FnOnce(&[u16], &mut T, &mut Self) -> V,
{
let mut ticket = self.values.checkout(value_id);
f(&ticket.value.0, &mut ticket.value.1, self);
let value = f(&ticket.value.0, &mut ticket.value.1, self);
self.values.restore(ticket);
value
}

/// Get mutable access to a node value along with the children
Expand Down

0 comments on commit 419fa1d

Please sign in to comment.