Skip to content

Commit 1a316e8

Browse files
committed
cksum: replace is_some_and with is_none_or
for better readability
1 parent 9e94692 commit 1a316e8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/uucore/src/lib/features/checksum.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,20 +583,17 @@ fn get_expected_digest_as_hex_string(
583583
) -> Option<Cow<str>> {
584584
let ck = &line_info.checksum;
585585

586-
// TODO MSRV 1.82, replace `is_some_and` with `is_none_or`
587-
// to improve readability. This closure returns True if a length hint provided
588-
// and the argument isn't the same as the hint.
589-
let against_hint = |len| len_hint.is_some_and(|l| l != len);
586+
let against_hint = |len| len_hint.is_none_or(|l| l == len);
590587

591588
if ck.len() % 2 != 0 {
592589
// If the length of the digest is not a multiple of 2, then it
593590
// must be improperly formatted (1 hex digit is 2 characters)
594591
return None;
595592
}
596593

597-
// If the digest can be decoded as hexadecimal AND it length match the
594+
// If the digest can be decoded as hexadecimal AND its length matches the
598595
// one expected (in case it's given), just go with it.
599-
if ck.as_bytes().iter().all(u8::is_ascii_hexdigit) && !against_hint(ck.len()) {
596+
if ck.as_bytes().iter().all(u8::is_ascii_hexdigit) && against_hint(ck.len()) {
600597
return Some(Cow::Borrowed(ck));
601598
}
602599

@@ -608,7 +605,7 @@ fn get_expected_digest_as_hex_string(
608605
.ok()
609606
.and_then(|s| {
610607
// Check the digest length
611-
if !against_hint(s.len()) {
608+
if against_hint(s.len()) {
612609
Some(s)
613610
} else {
614611
None

0 commit comments

Comments
 (0)