unwrap multiple items
This commit is contained in:
parent
2dd56871ef
commit
c83d847051
1 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,21 @@
|
||||||
use config::Config;
|
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(()) }
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue