summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsyn <isaqtm@gmail.com>2020-01-13 23:05:34 +0300
committersyn <isaqtm@gmail.com>2020-01-13 23:09:22 +0300
commit8b4941846fe0fd9b3f5db1a773b5808cece31c8d (patch)
treea6d15a6f9b2003eac3a3c983ee7da77ae955a1e9 /src
parent36d031aa0a874646174f042efeacca0035c177bd (diff)
downloadevr-8b4941846fe0fd9b3f5db1a773b5808cece31c8d.tar.gz
Some refactoring
Diffstat (limited to 'src')
-rw-r--r--src/backends/mod.rs1
-rw-r--r--src/conf.rs22
-rw-r--r--src/main.rs16
3 files changed, 15 insertions, 24 deletions
diff --git a/src/backends/mod.rs b/src/backends/mod.rs
index 729daa5..b013298 100644
--- a/src/backends/mod.rs
+++ b/src/backends/mod.rs
@@ -8,6 +8,7 @@ pub use clang::ClangBackend;
pub trait Backend {
fn get_template(&self) -> Option<&str>;
+
fn run(&self, fname: &Path) -> std::io::Result<()>;
fn try_guess_test(&self, fname: &Path) -> Option<PathBuf> {
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))
}
diff --git a/src/main.rs b/src/main.rs
index af6a547..0e97682 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use clap::{AppSettings};
+use clap::AppSettings;
use structopt::StructOpt;
use env_logger;
use log::{ trace, error };
@@ -53,15 +53,15 @@ fn main() {
trace!("{:#?}", config);
- let (action, result) =
- if src_path.exists() {
- ("run", config.run(&src_path))
- } else {
- ("make", config.make(&src_path))
- };
+ let result =
+ if src_path.exists() {
+ config.run(&src_path)
+ } else {
+ config.make(&src_path)
+ };
match result {
- Ok(_) => trace!("ok {}", action),
+ Ok(_) => trace!("ok"),
Err(err) => error!("{}", err)
}
}