unwrap multiple items

This commit is contained in:
Jake Howard 2017-07-17 20:34:20 +01:00
parent 2dd56871ef
commit c83d847051
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,5 +1,21 @@
use config::Config;
pub fn validate(config: Config) {
use std::vec::Vec;
pub fn unwrap_group(config: &Config, funcs: Vec<&Fn(&Config) -> Result<(), String>>) -> Result<(), String> {
for func in funcs.iter() {
let func_result = func(config);
if func_result.is_err() {
return Err(func_result.unwrap_err());
}
}
return Ok(());
}
pub fn validate(config: Config) -> Result<(), String> {
return unwrap_group(&config, vec!(
&|c| { Ok(()) }
));
}