Skip to content

Commit

Permalink
stackinputs: constructor accepting iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
hackaugusto committed Dec 1, 2023
1 parent 498943f commit 8a300e6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/stack/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ impl StackInputs {
// --------------------------------------------------------------------------------------------

/// Returns `[StackInputs]` from a list of values, reversing them into a stack.
pub fn new(mut values: Vec<Felt>) -> Result<Self, InputError> {
pub fn new<I>(values: I) -> Result<Self, InputError>
where
I: IntoIterator<Item = Felt>,
{
let mut values: Vec<Felt> = values.into_iter().collect();

if values.len() > MAX_STACK_INPUTS_SIZE {
Err(InputError::StackTooBig(values.len()))
} else {
Expand All @@ -37,8 +42,7 @@ impl StackInputs {
where
I: IntoIterator<Item = u64>,
{
let values: Vec<Felt> = iter.into_iter().map(Felt::from).collect();
Self::new(values)
Self::new(iter.into_iter().map(Felt::from))
}

// PUBLIC ACCESSORS
Expand Down

0 comments on commit 8a300e6

Please sign in to comment.