From 0e2e59607104def8efff70d82b2be47daf708854 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 26 Jul 2017 15:33:13 +0100 Subject: [PATCH] Code format --- src/config/mod.rs | 3 ++- src/config/read.rs | 10 ++++++++-- src/input.rs | 10 ++++++++-- src/utils.rs | 4 ++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 87547d7..9be3d58 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -32,7 +32,8 @@ impl Config { pub fn get_config() -> Result { let config_str = try!(read::read()); - let config = try!(result_prefix(serde_yaml::from_str(&config_str), "Config Parse Error".into())); + let config = + try!(result_prefix(serde_yaml::from_str(&config_str), "Config Parse Error".into())); try!(result_prefix(validate::validate(&config), "Config Validation Error".into())); return Ok(Config::new(config)); } diff --git a/src/config/read.rs b/src/config/read.rs index 806667a..559766f 100644 --- a/src/config/read.rs +++ b/src/config/read.rs @@ -16,9 +16,15 @@ fn get_config_path() -> PathBuf { pub fn read() -> Result { let config_path = get_config_path(); - let mut config_file = try!(result_override(File::open(&config_path), format!("Unable to find config file at {}", config_path.display()))); + let mut config_file = try!(result_override( + File::open(&config_path), + format!("Unable to find config file at {}", config_path.display()) + )); let mut contents = String::new(); - try!(result_override(config_file.read_to_string(&mut contents), format!("Failed to read config file at {}.", config_path.display()))); + try!(result_override( + config_file.read_to_string(&mut contents), + format!("Failed to read config file at {}.", config_path.display()) + )); return Ok(contents); } diff --git a/src/input.rs b/src/input.rs index 3bcde64..6ac29b8 100644 --- a/src/input.rs +++ b/src/input.rs @@ -7,8 +7,14 @@ use utils::result_override; pub fn read_input_files(files: Vec) -> Result { let mut input = String::new(); for input_file_path in files.iter() { - let mut input_file = try!(result_override(File::open(input_file_path), format!("Failed to open input file {}.", input_file_path.display()))); - try!(result_override(input_file.read_to_string(&mut input), format!("Failed to read input file {}.", input_file_path.display()))); + let mut input_file = try!(result_override( + File::open(input_file_path), + format!("Failed to open input file {}.", input_file_path.display()) + )); + try!(result_override( + input_file.read_to_string(&mut input), + format!("Failed to read input file {}.", input_file_path.display()) + )); } return Ok(input); } diff --git a/src/utils.rs b/src/utils.rs index 0315597..3472d7f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -4,7 +4,7 @@ use std::fmt::Debug; pub fn result_override(r: Result, msg: String) -> Result { return match r { Ok(t) => Ok(t), - Err(_) => Err(msg) + Err(_) => Err(msg), }; } @@ -12,6 +12,6 @@ pub fn result_override(r: Result, msg: String) -> Result(r: Result, prefix: String) -> Result { return match r { Ok(t) => Ok(t), - Err(e) => Err(format!("{}: {:?}", prefix, e)) + Err(e) => Err(format!("{}: {:?}", prefix, e)), }; }