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 MoveLibrary {
/// The underlying map.
map: IndexMap<StringKey, MoveData>,
map: IndexMap<StringKey, Arc<MoveData>>,
}
impl MoveLibrary {
@@ -22,10 +24,10 @@ impl MoveLibrary {
}
impl DataLibrary<'_, MoveData> for MoveLibrary {
fn map(&self) -> &IndexMap<StringKey, MoveData> {
fn map(&self) -> &IndexMap<StringKey, Arc<MoveData>> {
&self.map
}
fn get_modify(&mut self) -> &mut IndexMap<StringKey, MoveData> {
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<MoveData>> {
&mut self.map
}
}