From aa8428ffcb6afa33945dc4748d377aa6be5422ce Mon Sep 17 00:00:00 2001 From: Jacob Van Geffen Date: Tue, 17 Dec 2024 16:00:53 -0600 Subject: [PATCH] clippy --- src/game/aggregation.rs | 13 ++++++++----- src/range.rs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/game/aggregation.rs b/src/game/aggregation.rs index 66af650..ad1d685 100644 --- a/src/game/aggregation.rs +++ b/src/game/aggregation.rs @@ -52,7 +52,7 @@ fn fmt_floats(floats: &[f32], formatter: &mut std::fmt::Formatter<'_>) -> std::f ) } -fn report_header(actions: &Vec) -> String { +fn report_header(actions: &[Action]) -> String { format!( "Flop,Turn,River,Frequency,IP Eq,IP EV,IP EQR,OOP Eq,OOP EV,OOP EQR,{}", // Title for likelihood & EV per action @@ -113,13 +113,14 @@ impl Display for AggRow { formatter, "{},", flop_to_string(&self.flop) - .expect(format!("Row contains invalid flop cards: {:?}", &self.flop).as_str()), + .unwrap_or_else(|_| panic!("Row contains invalid flop cards: {:?}", &self.flop)) + .as_str(), )?; // Write turn and river let optional_card_to_string = |&opt| match opt { Some(card) => { - card_to_string(card).expect(format!("Row contains invalid card: {card}").as_str()) + card_to_string(card).unwrap_or_else(|_| panic!("Row contains invalid card: {card}")) } None => String::from(""), }; @@ -186,7 +187,9 @@ fn generate_all_lines_rec( return Ok(()); } - for action in action_tree.available_actions().to_owned() { + let all_actions = action_tree.available_actions().to_owned(); + + for action in all_actions { action_tree.play(action)?; generate_all_lines_rec(action_tree, lines)?; @@ -257,7 +260,7 @@ impl AggActionTree { fn init(prev_actions: Vec, available_actions: Vec) -> Self { AggActionTree { prev_actions, - available_actions: available_actions, + available_actions, child_trees: HashMap::new(), data: Vec::new(), } diff --git a/src/range.rs b/src/range.rs index 3984537..8521d5f 100644 --- a/src/range.rs +++ b/src/range.rs @@ -350,7 +350,7 @@ pub fn flop_to_string(flop: &[u8; 3]) -> Result { return Err("Cards must be unique".to_string()); } - let mut local_flop = flop.clone(); + let mut local_flop = *flop; local_flop.sort(); Ok(local_flop