1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::Variable;
use std::fmt::{Display, Error, Formatter};

impl Display for Variable {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
        write!(f, "{}", self.name)
    }
}

impl Variable {
    /// Human-readable name of this variable.
    pub fn get_name(&self) -> &String {
        &self.name
    }
}

#[cfg(test)]
mod tests {
    use crate::RegulatoryGraph;

    #[test]
    fn basic_variable_test() {
        let rg = RegulatoryGraph::new(vec!["A".to_string()]);
        let a = rg.find_variable("A").unwrap();
        let a = &rg[a];
        assert_eq!("A", a.to_string().as_str());
        assert_eq!("A", a.get_name());
    }
}