Initial work on outlining the dynamic side of the library.
This commit is contained in:
@@ -30,3 +30,33 @@ impl DataLibrary<'_, Item> for ItemLibrary {
|
||||
(&mut self.map, &mut self.list)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::static_data::items::item::Item;
|
||||
use crate::static_data::items::item_category::{BattleItemCategory, ItemCategory};
|
||||
use crate::static_data::libraries::data_library::DataLibrary;
|
||||
use crate::static_data::libraries::item_library::ItemLibrary;
|
||||
use std::collections::HashSet;
|
||||
|
||||
fn build_item() -> Item {
|
||||
Item::new(
|
||||
"foo",
|
||||
ItemCategory::MiscItem,
|
||||
BattleItemCategory::MiscBattleItem,
|
||||
100,
|
||||
HashSet::new(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn build() -> ItemLibrary {
|
||||
let mut lib = ItemLibrary::new(1);
|
||||
let m = build_item();
|
||||
// Borrow as mut so we can insert
|
||||
let w = &mut lib;
|
||||
w.add("foo", m);
|
||||
// Drops borrow as mut
|
||||
|
||||
lib
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user