diff options
author | syn <isaqtm@gmail.com> | 2020-01-13 23:05:34 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2020-01-13 23:09:22 +0300 |
commit | 8b4941846fe0fd9b3f5db1a773b5808cece31c8d (patch) | |
tree | a6d15a6f9b2003eac3a3c983ee7da77ae955a1e9 /src/conf.rs | |
parent | 36d031aa0a874646174f042efeacca0035c177bd (diff) | |
download | evr-8b4941846fe0fd9b3f5db1a773b5808cece31c8d.tar.gz |
Some refactoring
Diffstat (limited to 'src/conf.rs')
-rw-r--r-- | src/conf.rs | 22 |
1 files changed, 6 insertions, 16 deletions
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<Conf, Error> { } 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<Conf, Error> { let buf_result: Result<Conf, de::Error> = 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)) } |