pub trait Closure: BasicSnippet {
type Args: BFieldCodec;
// Required methods
fn rust_shadow(&self, stack: &mut Vec<BFieldElement>);
fn pseudorandom_args(
&self,
seed: [u8; 32],
bench_case: Option<BenchmarkCase>,
) -> Self::Args;
// Provided methods
fn corner_case_args(&self) -> Vec<Self::Args> { ... }
fn set_up_test_stack(&self, args: Self::Args) -> Vec<BFieldElement> { ... }
}
Expand description
A Closure is a piece of tasm code that modifies the top of the stack without access to memory or nondeterminism or standard input/output.
See also: function, algorithm, read_only_algorithm, procedure, accessor, mem_preserver
Required Associated Types§
Sourcetype Args: BFieldCodec
type Args: BFieldCodec
The arguments of this closure.
Because rust does not support variadic types (yet?), it is recommended to
use a tuple if the closure takes more than one argument. Because of the way
BFieldCodec
works for tuples, specify the element the closure expects on
top of the stack as the last element of the tuple.
Required Methods§
fn rust_shadow(&self, stack: &mut Vec<BFieldElement>)
Sourcefn pseudorandom_args(
&self,
seed: [u8; 32],
bench_case: Option<BenchmarkCase>,
) -> Self::Args
fn pseudorandom_args( &self, seed: [u8; 32], bench_case: Option<BenchmarkCase>, ) -> Self::Args
Given a seed, generate pseudorandom arguments, from which an initial stack can be constructed.