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
///
/// 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 {
length,
precompute,
max_steps,
step: 0,
solution: String::default(), // we actually set this later
wordlist: wlist
wordlist: wlist,
};
todo!();
@ -81,13 +86,14 @@ pub struct GameBuilder<WL: WordList> {
length: usize,
precompute: bool,
max_steps: usize,
wordlist: WL
wordlist: WL,
}
impl<WL: WordList> GameBuilder<WL> {
/// build a [`Game`] with the stored configuration
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)
}
@ -123,7 +129,7 @@ impl<WL: WordList> Default for GameBuilder<WL> {
length: super::DEFAULT_WORD_LENGTH,
precompute: false,
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)]
pub struct BuiltinWList {
words: super::WordMap
words: super::WordMap,
}
impl super::WordList for BuiltinWList {
@ -23,8 +23,6 @@ impl Default for BuiltinWList {
fn default() -> Self {
let words: super::WordMap = serde_json::from_str(RAW_WORDLIST_FILE).unwrap();
Self {
words
}
Self { words }
}
}

View File

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

View File

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