automatic cargo CI changes

This commit is contained in:
cscherrNT 2024-03-21 13:33:14 +00:00 committed by github-actions[bot]
parent 880826dd85
commit 1050401e42
4 changed files with 16 additions and 12 deletions

View File

@ -30,14 +30,19 @@ impl<WL: WordList> Game<WL> {
/// # Errors /// # Errors
/// ///
/// This function will return an error if . /// This function will return an error if .
pub(crate) fn build(length: usize, precompute: bool, max_steps: usize, wlist: WL) -> anyhow::Result<Self> { pub(crate) fn build(
length: usize,
precompute: bool,
max_steps: usize,
wlist: WL,
) -> anyhow::Result<Self> {
let _game = Game { let _game = Game {
length, length,
precompute, precompute,
max_steps, max_steps,
step: 0, step: 0,
solution: String::default(), // we actually set this later solution: String::default(), // we actually set this later
wordlist: wlist wordlist: wlist,
}; };
todo!(); todo!();
@ -81,13 +86,14 @@ pub struct GameBuilder<WL: WordList> {
length: usize, length: usize,
precompute: bool, precompute: bool,
max_steps: usize, max_steps: usize,
wordlist: WL wordlist: WL,
} }
impl<WL: WordList> GameBuilder<WL> { impl<WL: WordList> GameBuilder<WL> {
/// build a [`Game`] with the stored configuration /// build a [`Game`] with the stored configuration
pub fn build(self) -> anyhow::Result<Game<WL>> { pub fn build(self) -> anyhow::Result<Game<WL>> {
let game: Game<WL> = Game::build(self.length, self.precompute, self.max_steps, WL::default())?; let game: Game<WL> =
Game::build(self.length, self.precompute, self.max_steps, WL::default())?;
Ok(game) Ok(game)
} }
@ -123,7 +129,7 @@ impl<WL: WordList> Default for GameBuilder<WL> {
length: super::DEFAULT_WORD_LENGTH, length: super::DEFAULT_WORD_LENGTH,
precompute: false, precompute: false,
max_steps: super::DEFAULT_MAX_STEPS, max_steps: super::DEFAULT_MAX_STEPS,
wordlist: WL::default() wordlist: WL::default(),
} }
} }
} }

View File

@ -6,7 +6,7 @@ const RAW_WORDLIST_FILE: &str = include_str!("../../data/wordlists/en_US_3b1b_fr
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct BuiltinWList { pub struct BuiltinWList {
words: super::WordMap words: super::WordMap,
} }
impl super::WordList for BuiltinWList { impl super::WordList for BuiltinWList {
@ -23,8 +23,6 @@ impl Default for BuiltinWList {
fn default() -> Self { fn default() -> Self {
let words: super::WordMap = serde_json::from_str(RAW_WORDLIST_FILE).unwrap(); let words: super::WordMap = serde_json::from_str(RAW_WORDLIST_FILE).unwrap();
Self { Self { words }
words
}
} }
} }

View File

@ -1,5 +1,5 @@
use rand::{prelude::*, seq::IteratorRandom}; use rand::{prelude::*, seq::IteratorRandom};
use std::collections::HashMap;
use std::ops::RangeBounds; use std::ops::RangeBounds;
#[cfg(feature = "builtin_wlist")] #[cfg(feature = "builtin_wlist")]

View File

@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, PartialOrd)] #[derive(Clone, Debug, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Frequency { pub struct Frequency {
inner: f64 inner: f64,
} }
// PERF: Hash for String is probably a bottleneck // PERF: Hash for String is probably a bottleneck
pub type Word = String; pub type Word = String;
@ -15,7 +15,7 @@ pub type Word = String;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct WordMap { pub struct WordMap {
inner: HashMap<Word,Frequency> inner: HashMap<Word, Frequency>,
} }
impl WordMap { impl WordMap {