summaryrefslogtreecommitdiff
path: root/learn_21/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'learn_21/src/config.rs')
-rw-r--r--learn_21/src/config.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/learn_21/src/config.rs b/learn_21/src/config.rs
index e0f21c4..a99441a 100644
--- a/learn_21/src/config.rs
+++ b/learn_21/src/config.rs
@@ -92,11 +92,11 @@ pub fn parse_config(input: &str) -> Result<Config, ConfigError> {
if workers.is_none() {
return Err(ConfigError::MissingField("workers".to_string()));
}
-
- Ok(Config{
- host: host.unwrap(),
- port: port.unwrap().get(),
- workers: workers.unwrap().get(),
+
+ Ok(Config {
+ host: host.ok_or_else(|| ConfigError::MissingField("host".into()))?,
+ port: port.ok_or_else(|| ConfigError::MissingField("port".into()))?.get(),
+ workers: workers.ok_or_else(|| ConfigError::MissingField("workers".into()))?.get(),
})
}