*: young clippy back at it again

This commit is contained in:
2026-04-02 02:25:48 +01:00
parent 91b40ed412
commit 69c012e47a
3 changed files with 5 additions and 6 deletions

View File

@@ -78,11 +78,11 @@ impl Card {
} }
pub fn rank(&self) -> Option<Rank> { pub fn rank(&self) -> Option<Rank> {
self.playing_card().and_then(|pc| Some(pc.rank)) self.playing_card().map(|pc| pc.rank)
} }
pub fn suit(&self) -> Option<Suit> { pub fn suit(&self) -> Option<Suit> {
self.playing_card().and_then(|pc| Some(pc.suit)) self.playing_card().map(|pc| pc.suit)
} }
} }
@@ -226,7 +226,7 @@ mod traits_numerics {
impl From<PlayingCard> for i64 { impl From<PlayingCard> for i64 {
fn from(card: PlayingCard) -> i64 { fn from(card: PlayingCard) -> i64 {
let deck = card.deck as i64; let deck = card.deck;
let rank = card.rank as i64; let rank = card.rank as i64;
let suit = card.suit as i64; let suit = card.suit as i64;
(deck * 52) + (rank * 4) + suit (deck * 52) + (rank * 4) + suit

View File

@@ -93,8 +93,7 @@ fn try_poker_hand(num_jokers: usize, cards: &[Card]) -> Option<PokerType> {
let (highest_rank_freq, num_pairs) = { let (highest_rank_freq, num_pairs) = {
let mut highest_rank_freq = 0; let mut highest_rank_freq = 0;
let mut num_pairs = 0; let mut num_pairs = 0;
for i in 0..counter_ranks.len() { for rank_freq in counter_ranks {
let rank_freq = counter_ranks[i];
highest_rank_freq = std::cmp::max(rank_freq, highest_rank_freq); highest_rank_freq = std::cmp::max(rank_freq, highest_rank_freq);
if rank_freq == 2 { if rank_freq == 2 {
num_pairs += 1 num_pairs += 1

View File

@@ -29,7 +29,7 @@ fn main() {
} }
println!(); println!();
let hand = classify(&hand); let hand = classify(hand);
match hand { match hand {
Some(hand) => println!("{}", hand), Some(hand) => println!("{}", hand),
None => println!("Not a hand"), None => println!("Not a hand"),