Major amounts of progress

This commit is contained in:
2022-06-03 16:35:18 +02:00
parent c194c5d209
commit 310bf857d2
37 changed files with 1558 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ use std::collections::HashMap;
#[derive(Debug)]
pub struct ItemLibrary {
map: HashMap<String, Item>,
map: HashMap<String, Box<Item>>,
list: Vec<String>,
}
@@ -17,8 +17,8 @@ impl ItemLibrary {
}
}
impl DataLibrary<'_, Item> for ItemLibrary {
fn map(&self) -> &HashMap<String, Item> {
impl DataLibrary<'_, Box<Item>> for ItemLibrary {
fn map(&self) -> &HashMap<String, Box<Item>> {
&self.map
}
@@ -26,7 +26,7 @@ impl DataLibrary<'_, Item> for ItemLibrary {
&self.list
}
fn get_modify(&mut self) -> (&mut HashMap<String, Item>, &mut Vec<String>) {
fn get_modify(&mut self) -> (&mut HashMap<String, Box<Item>>, &mut Vec<String>) {
(&mut self.map, &mut self.list)
}
}
@@ -54,7 +54,7 @@ pub mod tests {
let m = build_item();
// Borrow as mut so we can insert
let w = &mut lib;
w.add("foo", m);
w.add("foo", Box::from(m));
// Drops borrow as mut
lib