Skip to content

Commit f835fc4

Browse files
oech3sylvestre
authored andcommitted
join: remove collapsible_if
1 parent 01b7177 commit f835fc4

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

src/uu/join/src/join.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,21 +1109,15 @@ fn exec<Sep: Separator>(
11091109
/// Check that keys for both files and for a particular file are not
11101110
/// contradictory and return the key index.
11111111
fn get_field_number(keys: Option<usize>, key: Option<usize>) -> UResult<usize> {
1112-
if let Some(keys) = keys {
1113-
if let Some(key) = key {
1114-
if keys != key {
1115-
// Show zero-based field numbers as one-based.
1116-
return Err(USimpleError::new(
1117-
1,
1118-
translate!("join-error-incompatible-fields", "field1" => (keys + 1), "field2" => (key + 1)),
1119-
));
1120-
}
1121-
}
1122-
1123-
return Ok(keys);
1112+
match (keys, key) {
1113+
// Show zero-based field numbers as one-based.
1114+
(Some(k1), Some(k2)) if k1 != k2 => Err(USimpleError::new(
1115+
1,
1116+
translate!("join-error-incompatible-fields", "field1" => (k1 + 1), "field2" => (k2 + 1)),
1117+
)),
1118+
(Some(k), _) | (_, Some(k)) => Ok(k),
1119+
(None, None) => Ok(0),
11241120
}
1125-
1126-
Ok(key.unwrap_or(0))
11271121
}
11281122

11291123
/// Parse the specified field string as a natural number and return

0 commit comments

Comments
 (0)