Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d21a52b

Browse files
committed
Simplify sym converter logic
1 parent 8be88f1 commit d21a52b

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

src/cli.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,13 @@ fn convert_symbolic_quantity<S: Into<String>>(s: S) -> std::result::Result<u64,
238238

239239
let quantifier = s[digits.len()..].trim();
240240

241-
if quantifier.len() > 1 || !"KMGT".contains(&quantifier) {
242-
return Err("Unkown quantifier");
243-
}
244-
245241
let exp = match quantifier {
246242
"" => 0,
247243
"K" => 1,
248244
"M" => 2,
249245
"G" => 3,
250246
"T" => 4,
251-
_ => unreachable!(),
247+
_ => return Err("Unkown quantifier"),
252248
};
253249

254250
Ok(digits.parse::<u64>().unwrap() * 1024_u64.pow(exp))

0 commit comments

Comments
 (0)