REFACTOR: proper naming for the yaml to ucg conversion function.

This commit is contained in:
Jeremy Wall 2019-02-20 19:57:37 -06:00
parent ff54452766
commit f8c035e535

View File

@ -71,7 +71,7 @@ impl YamlConverter {
Ok(yaml_val) Ok(yaml_val)
} }
fn convert_json_val(&self, v: &serde_yaml::Value) -> Result<Val, Box<dyn Error>> { fn convert_yaml_val(&self, v: &serde_yaml::Value) -> Result<Val, Box<dyn Error>> {
Ok(match v { Ok(match v {
serde_yaml::Value::String(s) => Val::Str(s.clone()), serde_yaml::Value::String(s) => Val::Str(s.clone()),
serde_yaml::Value::Number(n) => { serde_yaml::Value::Number(n) => {
@ -86,7 +86,7 @@ impl YamlConverter {
serde_yaml::Value::Sequence(l) => { serde_yaml::Value::Sequence(l) => {
let mut vs = Vec::with_capacity(l.len()); let mut vs = Vec::with_capacity(l.len());
for aval in l { for aval in l {
vs.push(Rc::new(self.convert_json_val(aval)?)); vs.push(Rc::new(self.convert_yaml_val(aval)?));
} }
Val::List(vs) Val::List(vs)
} }
@ -106,7 +106,7 @@ impl YamlConverter {
} }
}; };
eprintln!("yaml key is: {}", key); eprintln!("yaml key is: {}", key);
fs.push((key, Rc::new(self.convert_json_val(value)?))); fs.push((key, Rc::new(self.convert_yaml_val(value)?)));
} }
Val::Tuple(fs) Val::Tuple(fs)
} }
@ -137,6 +137,6 @@ impl Converter for YamlConverter {
impl Importer for YamlConverter { impl Importer for YamlConverter {
fn import(&self, bytes: &[u8]) -> ImportResult { fn import(&self, bytes: &[u8]) -> ImportResult {
let json_val = serde_yaml::from_slice(bytes)?; let json_val = serde_yaml::from_slice(bytes)?;
Ok(Rc::new(self.convert_json_val(&json_val)?)) Ok(Rc::new(self.convert_yaml_val(&json_val)?))
} }
} }