From 297a8454f61bc8358b82ea4a08ea1d4c663a463a Mon Sep 17 00:00:00 2001 From: projectmoon Date: Thu, 17 Dec 2020 21:20:45 +0000 Subject: [PATCH] Avoid cloning when counting successes. --- src/cofd/dice.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cofd/dice.rs b/src/cofd/dice.rs index 8251e50..98143db 100644 --- a/src/cofd/dice.rs +++ b/src/cofd/dice.rs @@ -190,12 +190,12 @@ impl DicePoolRoll { } pub fn successes(&self) -> i32 { - let successes = self + let successes: usize = self .rolls .iter() - .cloned() - .filter(|&roll| roll >= self.modifiers.success_on) + .filter(|&roll| *roll >= self.modifiers.success_on) .count(); + i32::try_from(successes).unwrap_or(0) }