use rvs; use std::io; use std::rc::Rc; use std::cell::RefCell; pub fn expr_to_var(expr: S) -> rvs::Result>>> where S: AsRef, { let s = format!("variable = {};", expr.as_ref()); println!("Parsing {}", expr.as_ref()); let model = rvs::parse(&Default::default(), &s)?; match model.get_variable_by_name("variable") { Some(variable) => Ok(Rc::clone(variable)), None => Err(rvs::Error::Io(io::Error::new( io::ErrorKind::NotFound, "cannot find 'variable' in model", ))), } }