Skip to content

Commit 6b53e04

Browse files
committed
Avoid TryFrom, since it is not in stable yet
1 parent 3d1bbcb commit 6b53e04

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/config.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn read_config(manifest_path: PathBuf) -> Result<Config, ErrorString>
1717
}
1818

1919
pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorString> {
20-
use std::{convert::TryFrom, fs::File, io::Read};
20+
use std::{fs::File, io::Read};
2121
let cargo_toml: Value = {
2222
let mut content = String::new();
2323
File::open(&manifest_path)
@@ -54,10 +54,11 @@ pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorS
5454
for (key, value) in metadata {
5555
match (key.as_str(), value.clone()) {
5656
("default-target", Value::String(s)) => config.default_target = From::from(s),
57-
("test-timeout", Value::Integer(s)) => {
58-
config.test_timeout = u64::try_from(s)
59-
.map_err(|err| format!("test-timeout is not valid: {}", err))?
60-
.into()
57+
("test-timeout", Value::Integer(timeout)) if timeout.is_negative() => {
58+
Err(format!("test-timeout must not be negative"))?
59+
}
60+
("test-timeout", Value::Integer(timeout)) => {
61+
config.test_timeout = Some(timeout as u64);
6162
}
6263
("run-command", Value::Array(array)) => {
6364
let mut command = Vec::new();

0 commit comments

Comments
 (0)