1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use super::{variables::Variables, WitnessCell};
use ark_ff::Field;

/// Witness cell assigned from a variable
/// See [Variables] for more details
pub struct VariableCell<'a> {
    name: &'a str,
}

impl<'a> VariableCell<'a> {
    /// Create witness cell assigned from a variable name
    pub fn create(name: &'a str) -> Box<VariableCell<'a>> {
        Box::new(VariableCell { name })
    }
}

impl<'a, F: Field, const W: usize> WitnessCell<F, F, W> for VariableCell<'a> {
    fn value(&self, _witness: &mut [Vec<F>; W], variables: &Variables<F>, _index: usize) -> F {
        variables[self.name]
    }
}