From 8b4941846fe0fd9b3f5db1a773b5808cece31c8d Mon Sep 17 00:00:00 2001 From: syn Date: Mon, 13 Jan 2020 23:05:34 +0300 Subject: Some refactoring --- src/conf.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/conf.rs') diff --git a/src/conf.rs b/src/conf.rs index eec5d86..e36a932 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -1,4 +1,4 @@ -use serde_derive::{Serialize, Deserialize}; +use serde_derive::{ Serialize, Deserialize }; use std::path::{ PathBuf, Path }; use toml::de; use log::{ error, trace }; @@ -57,15 +57,9 @@ impl Conf { trace!("Written some bytes to {}", fname.to_string_lossy()); Ok(()) } - - #[allow(unused)] - pub fn get_compiler_args(&self) -> String { - "somedef".to_string() - } } - pub fn get_conf() -> Conf { match get_conf_maybe() { Ok(c) => c, @@ -89,7 +83,6 @@ pub fn get_conf_maybe() -> Result { } if !current.pop() { - error!("Not a evr subtree."); return Err(Error::new(ErrorKind::NotFound, "Not a evr subtree")); } }; @@ -98,13 +91,10 @@ pub fn get_conf_maybe() -> Result { let buf_result: Result = de::from_str(&raw_buf); - match buf_result { - Ok(mut buf) => { + buf_result + .map(|mut buf| { buf.path = Some(path.clone()); - Ok(buf) - }, - Err(err) => { - Err(Error::new(ErrorKind::InvalidData, err)) - } - } + buf + }) + .map_err(|err| Error::new(ErrorKind::InvalidData, err)) } -- cgit v1.2.1-18-gbd029