Remove lifetime mess, replace a lot of code with Arc instead of borrows.
Some checks failed
continuous-integration/drone/push Build is failing

This cleans up the codebase massively, and allows me to maintain some semblance of sanity.
This commit is contained in:
2022-08-20 13:17:20 +02:00
parent 2d4253e155
commit 55cc0906c9
34 changed files with 320 additions and 366 deletions

View File

@@ -1,3 +1,5 @@
use std::sync::Arc;
use indexmap::IndexMap;
use crate::static_data::DataLibrary;
@@ -9,7 +11,7 @@ use crate::StringKey;
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct ItemLibrary {
/// The underlying data structure.
map: IndexMap<StringKey, Box<Item>>,
map: IndexMap<StringKey, Arc<Item>>,
}
impl ItemLibrary {
@@ -21,12 +23,12 @@ impl ItemLibrary {
}
}
impl DataLibrary<'_, Box<Item>> for ItemLibrary {
fn map(&self) -> &IndexMap<StringKey, Box<Item>> {
impl DataLibrary<'_, Item> for ItemLibrary {
fn map(&self) -> &IndexMap<StringKey, Arc<Item>> {
&self.map
}
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Box<Item>> {
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<Item>> {
&mut self.map
}
}