Skip to content

Commit e58e8dd

Browse files
committed
fix: resolve cargo clippy warnings
Collapse nested if blocks into match arm guards in yaku.rs and use RangeInclusive::contains in agari-python/src/lib.rs.
1 parent 63d443a commit e58e8dd

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

crates/agari-core/src/yaku.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -491,27 +491,25 @@ pub fn detect_yaku_with_context(
491491
let mut concealed_triplets = 0;
492492
for meld in melds {
493493
match meld {
494-
Meld::Koutsu(tile, is_open_meld) => {
494+
Meld::Koutsu(tile, is_open_meld)
495495
// A triplet is concealed if:
496496
// 1. It's not an open pon
497497
// 2. For ron, the winning tile did NOT complete this triplet,
498498
// OR the winning tile could have completed a sequence instead
499-
if !is_open_meld {
500-
if context.win_type == WinType::Tsumo {
501-
concealed_triplets += 1;
502-
} else if let Some(wt) = context.winning_tile
503-
&& (*tile != wt || winning_tile_completes_sequence)
504-
{
505-
concealed_triplets += 1;
506-
}
507-
}
508-
}
509-
Meld::Kan(_, kan_type) => {
510-
// Closed kans count as concealed triplets
511-
if !kan_type.is_open() {
499+
if !is_open_meld =>
500+
{
501+
if context.win_type == WinType::Tsumo {
502+
concealed_triplets += 1;
503+
} else if let Some(wt) = context.winning_tile
504+
&& (*tile != wt || winning_tile_completes_sequence)
505+
{
512506
concealed_triplets += 1;
513507
}
514508
}
509+
// Closed kans count as concealed triplets
510+
Meld::Kan(_, kan_type) if !kan_type.is_open() => {
511+
concealed_triplets += 1;
512+
}
515513
_ => {}
516514
}
517515
}

crates/agari-python/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn valid_chi_combinations(hand: Vec<u8>, discarded_tile: u8) -> PyResult<Vec<(u8
7575
combos.push(((d - 2) as u8, (d - 1) as u8));
7676
}
7777
// Discarded tile is the MIDDLE of sequence: (d-1, d, d+1)
78-
if val >= 1 && val <= 7 && hand[d - 1] > 0 && hand[d + 1] > 0 {
78+
if (1..=7).contains(&val) && hand[d - 1] > 0 && hand[d + 1] > 0 {
7979
combos.push(((d - 1) as u8, (d + 1) as u8));
8080
}
8181
// Discarded tile is the LOW end of sequence: (d, d+1, d+2)

0 commit comments

Comments
 (0)