From acffc6d5da2e23c580cb11ccd28ac933caf57c53 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Wed, 2 Oct 2019 20:56:09 -0500 Subject: [PATCH] MAINT: cargo fmt --- bin/build_main.rs | 12 ++++++++++-- src/convert/yaml.rs | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bin/build_main.rs b/bin/build_main.rs index a69e8d9..5a06b46 100644 --- a/bin/build_main.rs +++ b/bin/build_main.rs @@ -20,7 +20,12 @@ fn generate_rust_module() -> String { let fixed_path_str = path_str.replace(std::path::MAIN_SEPARATOR, "/"); if path.is_file() && !path_str.ends_with("_test.ucg") { println!("Adding lib file: {}", path_str); - let out_path = PathBuf::from(format!("{}{}{}", out_dir, std::path::MAIN_SEPARATOR, path_str)); + let out_path = PathBuf::from(format!( + "{}{}{}", + out_dir, + std::path::MAIN_SEPARATOR, + path_str + )); // We have to copy the file into out out directory to ensure that we // have a reliable way for the stdlib.rs module file to include them // from. @@ -28,7 +33,10 @@ fn generate_rust_module() -> String { std::fs::copy(&path_str, &out_path).unwrap(); let include = format!( "\tstdlib.insert(\n\t\tr\"{}\".to_string(),\n\t\tinclude_str!(r\"{}{}{}\"));\n", - fixed_path_str, out_dir, std::path::MAIN_SEPARATOR, path_str + fixed_path_str, + out_dir, + std::path::MAIN_SEPARATOR, + path_str ); rust_lib.push_str(&include); rust_lib.push_str("\n"); diff --git a/src/convert/yaml.rs b/src/convert/yaml.rs index f5f57ee..97f1625 100644 --- a/src/convert/yaml.rs +++ b/src/convert/yaml.rs @@ -124,16 +124,16 @@ impl YamlConverter { serde_yaml::Value::Mapping(m) => { let mut fs = Vec::with_capacity(m.len()); self.merge_mapping_keys(&mut fs, m)?; - fs.reverse(); - let mut seen_keys = BTreeSet::new(); - let mut collapsed = Vec::with_capacity(fs.len()); - for (k, val) in fs { - if !seen_keys.contains(&k) { - collapsed.push((k.clone(), val)); - seen_keys.insert(k); - } - } - collapsed.reverse(); + fs.reverse(); + let mut seen_keys = BTreeSet::new(); + let mut collapsed = Vec::with_capacity(fs.len()); + for (k, val) in fs { + if !seen_keys.contains(&k) { + collapsed.push((k.clone(), val)); + seen_keys.insert(k); + } + } + collapsed.reverse(); Val::Tuple(collapsed) } })