pub struct ChainMap<const NUM_INPUT_LISTS: usize> { /* private fields */ }Expand description
Applies a given function f to every element of all given lists, collecting
the new elements into a new list.
The given function f must produce elements of a type for which the encoded
length is statically known. The input type may have either
statically or dynamically known length:
- In the static case, the entire element is placed on the stack before
passing control to
f. - In the dynamic case, a memory pointer to the encoded element and the
item’s length is placed on the stack before passing control to
f. The input list must be encoded according toBFieldCodec. Otherwise, behavior ofChainMapis undefined!
The stack layout is independent of the list currently being processed. This
allows the InnerFunction f to use runtime parameters from the stack.
Note that the chain map requires a certain number of stack registers for
internal purposes. This number can be accessed through
ChainMap::NUM_INTERNAL_REGISTERS. As mentioned above, the stack layout
upon starting execution of f depends on the input type’s
static length. In the static case, the stack layout is:
// _ <accessible> [_; ChainMap::<N>::NUM_INTERNAL_REGISTERS] [input_element; len]In the case of input elements with a dynamic length, the stack layout is:
// _ <accessible> [_; ChainMap::<N>::NUM_INTERNAL_REGISTERS] *elem_i elem_i_lenImplementations§
Source§impl<const NUM_INPUT_LISTS: usize> ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> ChainMap<NUM_INPUT_LISTS>
Sourcepub const NUM_INTERNAL_REGISTERS: usize
pub const NUM_INTERNAL_REGISTERS: usize
The number of registers required internally. See ChainMap for additional
details.
Sourcepub fn new(f: InnerFunction) -> Self
pub fn new(f: InnerFunction) -> Self
§Panics
- if the input type has [static length] and takes up
OpStackElement::COUNTor more words - if the input type has dynamic length and is anything but a tuple
(_,BFieldElement) - if the output type takes up
OpStackElement::COUNT- 1or more words - if the output type does not have a static length
Trait Implementations§
Source§impl<const NUM_INPUT_LISTS: usize> BasicSnippet for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> BasicSnippet for ChainMap<NUM_INPUT_LISTS>
fn inputs(&self) -> Vec<(DataType, String)>
fn outputs(&self) -> Vec<(DataType, String)>
fn entrypoint(&self) -> String
fn code(&self, library: &mut Library) -> Vec<LabelledInstruction>
fn annotated_code(&self, library: &mut Library) -> Vec<LabelledInstruction>
fn link_for_isolated_run(&self) -> Vec<LabelledInstruction>
Source§fn init_stack_for_isolated_run(&self) -> Vec<BFieldElement>
fn init_stack_for_isolated_run(&self) -> Vec<BFieldElement>
fn stack_diff(&self) -> isize
Auto Trait Implementations§
impl<const NUM_INPUT_LISTS: usize> Freeze for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> !RefUnwindSafe for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> !Send for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> !Sync for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> Unpin for ChainMap<NUM_INPUT_LISTS>
impl<const NUM_INPUT_LISTS: usize> !UnwindSafe for ChainMap<NUM_INPUT_LISTS>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more