crt: give Bundle iter() and index ability
//! Module containing `BundleGadgets`, which are mostly CRT-based gadgets for Fancy.
+use std::ops::Index;
+
use itertools::Itertools;
use super::{to_vec_option, Fancy, HasModulus};
@@ -59,6 +61,19 @@ impl<W: Clone + HasModulus> Bundle<W> {
pub fn extract(&mut self, wire_index: usize) -> W {
self.0.remove(wire_index)
}
+
+ /// Access the underlying iterator
+ pub fn iter(&self) -> std::slice::Iter<W> {
+ self.0.iter()
+ }
+}
+
+impl <W: Clone + HasModulus> Index<usize> for Bundle<W> {
+ type Output = W;
+
+ fn index(&self, idx: usize) -> &Self::Output {
+ self.0.index(idx)
+ }
}
/// Extension trait for `Fancy` providing advanced gadgets based on bundles of wires.
