refactor(evaluation): move evaluation to a new module
cargo devel CI / cargo CI (push) Successful in 1m48s Details

This commit is contained in:
Christoph J. Scherr 2024-07-22 14:54:22 +02:00
parent 8a48498182
commit 36347d1661
2 changed files with 36 additions and 0 deletions

33
src/game/evaluation.rs Normal file
View File

@ -0,0 +1,33 @@
use std::convert::Infallible;
use std::str::FromStr;
use super::response::Status;
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Evaluation {
inner: Vec<EvaluationUnit>,
}
pub type EvaluationUnit = (char, Status);
impl IntoIterator for Evaluation {
type Item = EvaluationUnit;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.inner.into_iter()
}
}
impl From<Vec<EvaluationUnit>> for Evaluation {
fn from(value: Vec<EvaluationUnit>) -> Self {
Self { inner: value }
}
}
impl FromStr for Evaluation {
type Err = Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
// TODO: make this proper
Ok(vec![('x', Status::None)].into())
}
}

View File

@ -9,6 +9,9 @@ use libpt::log::{debug, trace};
pub mod response;
use response::GuessResponse;
pub mod evaluation;
use evaluation::*;
pub mod summary;
use self::response::{Evaluation, Status};