Skip to content

Commit 9ffec60

Browse files
authored
Merge pull request #74 from hanneskaeufler/hk-tiny-refactor
Apply small refactor for consistency
2 parents ac5250c + 622eed3 commit 9ffec60

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/arg_parsers/filter.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,9 @@ impl TryFrom<&OsStr> for Filter {
4747
type Error = ArgParseErr;
4848

4949
fn try_from(s: &OsStr) -> Result<Self, Self::Error> {
50-
if let Some(s_utf8) = s.to_str() {
51-
if let Ok(known_filter) = Self::try_from(s_utf8) {
52-
return Ok(known_filter);
53-
}
54-
}
55-
Err(ArgParseErr {
56-
message: Some(format!(
57-
"unrecognized image filter `{}'",
58-
s.to_string_lossy()
59-
)),
60-
})
50+
s.to_str()
51+
.ok_or_else(|| ArgParseErr::with_msg("non-utf8 filter value"))
52+
.and_then(|val| Filter::try_from(val).map_err(ArgParseErr::with_msg))
6153
}
6254
}
6355

0 commit comments

Comments
 (0)