From c76c1d2d78ac7d5019af72d27c6ffd0b6a21107f Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Thu, 1 Aug 2024 15:46:05 +0200 Subject: [PATCH] refactor(evaluation): add some public methods and trait impls --- src/game/evaluation.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/game/evaluation.rs b/src/game/evaluation.rs index fa4b1a0..eddff1e 100644 --- a/src/game/evaluation.rs +++ b/src/game/evaluation.rs @@ -68,6 +68,18 @@ impl Evaluation { } Ok(v.into()) } + + pub fn inner(&self) -> &Vec { + &self.inner + } + + pub fn inner_mut(&mut self) -> &mut Vec { + &mut self.inner + } + + pub fn guess(&self) -> Word { + Word::from(self) + } } impl IntoIterator for Evaluation { @@ -87,6 +99,12 @@ impl From> for Evaluation { impl From for Word { fn from(value: Evaluation) -> Self { - Word::from(value.inner.into_iter().map(|v| v.0).collect::()) + Word::from(value.inner.iter().map(|v| v.0).collect::()) + } +} + +impl From<&Evaluation> for Word { + fn from(value: &Evaluation) -> Self { + Word::from(value.inner.iter().map(|v| v.0).collect::()) } }