Skip to content

Commit

Permalink
feat: Add From<FunctionInitialState> for InitVmState implementation
Browse files Browse the repository at this point in the history
Allows us to call `.into()` on a FunctionInitialState for use with e.g.
`negative_test` test-helper function.
  • Loading branch information
Sword-Smith committed Sep 10, 2024
1 parent 67ce638 commit 1f0d0c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasm-lib/src/traits/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::snippet_bencher::write_benchmarks;
use crate::snippet_bencher::BenchmarkCase;
use crate::snippet_bencher::NamedBenchmarkResult;
use crate::test_helpers::test_rust_equivalence_given_complete_state;
use crate::InitVmState;
use crate::VmHasher;

use super::basic_snippet::BasicSnippet;
Expand Down Expand Up @@ -55,6 +56,17 @@ pub struct FunctionInitialState {
pub memory: HashMap<BFieldElement, BFieldElement>,
}

impl From<FunctionInitialState> for InitVmState {
fn from(value: FunctionInitialState) -> Self {
let nd = NonDeterminism::default().with_ram(value.memory);
Self {
stack: value.stack,
nondeterminism: nd,
..Default::default()
}
}
}

pub struct ShadowedFunction<F: Function + 'static> {
pub function: Rc<RefCell<F>>,
}
Expand Down

0 comments on commit 1f0d0c2

Please sign in to comment.