Skip to content

Commit 1f0d0c2

Browse files
committed
feat: Add From<FunctionInitialState> for InitVmState implementation
Allows us to call `.into()` on a FunctionInitialState for use with e.g. `negative_test` test-helper function.
1 parent 67ce638 commit 1f0d0c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tasm-lib/src/traits/function.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::snippet_bencher::write_benchmarks;
1111
use crate::snippet_bencher::BenchmarkCase;
1212
use crate::snippet_bencher::NamedBenchmarkResult;
1313
use crate::test_helpers::test_rust_equivalence_given_complete_state;
14+
use crate::InitVmState;
1415
use crate::VmHasher;
1516

1617
use super::basic_snippet::BasicSnippet;
@@ -55,6 +56,17 @@ pub struct FunctionInitialState {
5556
pub memory: HashMap<BFieldElement, BFieldElement>,
5657
}
5758

59+
impl From<FunctionInitialState> for InitVmState {
60+
fn from(value: FunctionInitialState) -> Self {
61+
let nd = NonDeterminism::default().with_ram(value.memory);
62+
Self {
63+
stack: value.stack,
64+
nondeterminism: nd,
65+
..Default::default()
66+
}
67+
}
68+
}
69+
5870
pub struct ShadowedFunction<F: Function + 'static> {
5971
pub function: Rc<RefCell<F>>,
6072
}

0 commit comments

Comments
 (0)