More documentation.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-01 17:07:22 +02:00
parent 03f5e3bb5a
commit 8f6ecdd4ad
35 changed files with 721 additions and 262 deletions

View File

@@ -1,35 +1,31 @@
use hashbrown::HashMap;
use indexmap::IndexMap;
use crate::static_data::DataLibrary;
use crate::static_data::MoveData;
use crate::StringKey;
/// A library to store all data for moves.
#[derive(Debug)]
pub struct MoveLibrary {
map: HashMap<StringKey, MoveData>,
list: Vec<StringKey>,
/// The underlying map.
map: IndexMap<StringKey, MoveData>,
}
impl MoveLibrary {
/// Instantiates a new Move Library.
pub fn new(capacity: usize) -> MoveLibrary {
MoveLibrary {
map: HashMap::with_capacity(capacity),
list: Vec::with_capacity(capacity),
map: IndexMap::with_capacity(capacity),
}
}
}
impl DataLibrary<'_, MoveData> for MoveLibrary {
fn map(&self) -> &HashMap<StringKey, MoveData> {
fn map(&self) -> &IndexMap<StringKey, MoveData> {
&self.map
}
fn list_values(&self) -> &Vec<StringKey> {
&self.list
}
fn get_modify(&mut self) -> (&mut HashMap<StringKey, MoveData>, &mut Vec<StringKey>) {
(&mut self.map, &mut self.list)
fn get_modify(&mut self) -> &mut IndexMap<StringKey, MoveData> {
&mut self.map
}
}
@@ -45,7 +41,7 @@ pub mod tests {
fn build_move() -> MoveData {
MoveData::new(
&"foo".into(),
0,
0.into(),
MoveCategory::Physical,
100,
100,