From c7d89e4c030e5bc57e83546b584c327ad5a5dd37 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 10 Sep 2017 16:26:02 +0100 Subject: [PATCH] Format --- src/build/csl.rs | 15 +++++++++++---- src/config/validate.rs | 25 ++++++++++++++++++++++--- src/config/validate_types.rs | 7 +++++-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/build/csl.rs b/src/build/csl.rs index f69758c..97a4eab 100644 --- a/src/build/csl.rs +++ b/src/build/csl.rs @@ -17,13 +17,20 @@ fn get_temp_file() -> PathBuf { fn get_csl_data(csl_name: String) -> Result { - let zip_file = try!(result_override(File::open(get_csl_path()), "Failed to read CSL zip".into())); - let mut archive = try!(result_override(ZipArchive::new(zip_file), "Failed to load zip file".into())); + let zip_file = + try!(result_override(File::open(get_csl_path()), "Failed to read CSL zip".into())); + let mut archive = + try!(result_override(ZipArchive::new(zip_file), "Failed to load zip file".into())); debug_assert!(archive.len() >= 10); - let mut csl_zip_file = try!(result_override(archive.by_name(&format!("{}.csl", csl_name)), format!("Can't find CSL {}.", csl_name))); + let mut csl_zip_file = try!(result_override( + archive.by_name(&format!("{}.csl", csl_name)), + format!("Can't find CSL {}.", csl_name) + )); debug_assert!(csl_zip_file.size() > 0); let mut csl_buffer = String::new(); - try!(result_override(csl_zip_file.read_to_string(&mut csl_buffer), "Failed to read CSL".into())); + try!( + result_override(csl_zip_file.read_to_string(&mut csl_buffer), "Failed to read CSL".into()) + ); return Ok(csl_buffer); } diff --git a/src/config/validate.rs b/src/config/validate.rs index d23f60d..dc8c35b 100644 --- a/src/config/validate.rs +++ b/src/config/validate.rs @@ -52,8 +52,21 @@ fn check_references(config: Value) -> ValidationResult { return Ok(()); } let references = config.get("references").unwrap(); - let bibliography = resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()); - let valid_extensions = vec!["bib", "bibtex", "copac", "json", "yaml", "enl", "xml", "wos", "medline", "mods", "ris"]; + let bibliography = + resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()); + let valid_extensions = vec![ + "bib", + "bibtex", + "copac", + "json", + "yaml", + "enl", + "xml", + "wos", + "medline", + "mods", + "ris", + ]; if !bibliography.exists() { return Err(format!("Can't find bibliography at {}.", bibliography.display())); } @@ -78,6 +91,12 @@ pub fn unwrap_group(config: Value, funcs: Vec<&Fn(Value) -> ValidationResult>) - pub fn validate(config: Value) -> ValidationResult { return unwrap_group( config, - vec![&check_required_keys, &check_config_types, &check_input_files, &check_output_files, &check_references] + vec![ + &check_required_keys, + &check_config_types, + &check_input_files, + &check_output_files, + &check_references, + ] ); } diff --git a/src/config/validate_types.rs b/src/config/validate_types.rs index 0804a9b..ce83ddd 100644 --- a/src/config/validate_types.rs +++ b/src/config/validate_types.rs @@ -57,7 +57,7 @@ fn check_title(config: Value) -> ValidationResult { fn check_references(config: Value) -> ValidationResult { if config.get("references").is_none() { - return Ok(()); // references is optional, dont type it if it's not there + return Ok(()); // references is optional, dont type it if it's not there } if !config.get("references").unwrap().is_mapping() { return Err("References should be mapping".into()); @@ -82,5 +82,8 @@ fn check_references(config: Value) -> ValidationResult { pub fn check_config_types(config: Value) -> ValidationResult { - return unwrap_group(config, vec![&check_root, &check_input, &check_output, &check_title, &check_references]); + return unwrap_group( + config, + vec![&check_root, &check_input, &check_output, &check_title, &check_references] + ); }