use super::{variables::Variables, WitnessCell};
use ark_ff::Field;
pub struct IndexCell<'a> {
name: &'a str,
length: usize,
}
impl<'a> IndexCell<'a> {
pub fn create(name: &'a str, from: usize, to: usize) -> Box<IndexCell<'a>> {
Box::new(IndexCell {
name,
length: to - from,
})
}
}
impl<'a, F: Field, const W: usize> WitnessCell<F, Vec<F>, W> for IndexCell<'a> {
fn value(&self, _witness: &mut [Vec<F>; W], variables: &Variables<Vec<F>>, index: usize) -> F {
assert!(index < self.length, "index out of bounds of `IndexCell`");
variables[self.name][index]
}
fn length(&self) -> usize {
self.length
}
}