Skip to content

Commit

Permalink
Generic witness: implement iterator with lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Feb 29, 2024
1 parent 9fd540c commit 6464e67
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions msm/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ impl<const N: usize, T: Zero + Clone> Default for Witness<N, T> {

// IMPLEMENTATION OF ITERATORS FOR THE WITNESS STRUCTURE

impl<'lt, const N: usize, G> IntoIterator for &'lt Witness<N, G> {
type Item = &'lt G;
type IntoIter = std::vec::IntoIter<&'lt G>;

fn into_iter(self) -> Self::IntoIter {
let mut iter_contents = Vec::with_capacity(N);
iter_contents.extend(&self.cols);
iter_contents.into_iter()
}
}

impl<const N: usize, F: Clone> IntoIterator for Witness<N, F> {
type Item = F;
type IntoIter = std::vec::IntoIter<F>;
Expand Down

0 comments on commit 6464e67

Please sign in to comment.