Skip to content

Commit

Permalink
refactor(2023): use deref instead of slice reference for day 7
Browse files Browse the repository at this point in the history
Minor refactor, but looks a cleaner without any performance hit
  • Loading branch information
believer committed Dec 7, 2023
1 parent 35803dd commit 771044c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rust/2023/src/day_07.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use itertools::Itertools;
use std::{ops::Add, str::Chars};
use std::{
ops::{Add, Deref},
str::Chars,
};

// Day 7: Camel Cards
//
Expand Down Expand Up @@ -61,7 +64,7 @@ impl From<&Chars<'_>> for HandType {
// Simplify counting and sorting using Itertools
let hand_type = value.clone().counts().values().sorted().join("");

match &hand_type[..] {
match hand_type.deref() {
"11111" => Self::HighCard,
"1112" => Self::OnePair,
"122" => Self::TwoPairs,
Expand Down

0 comments on commit 771044c

Please sign in to comment.