pub struct Inventory {
pub items: Vec<Option<Item>>,
pub capacity: usize,
pub max_weight: f32,
}Fields§
§items: Vec<Option<Item>>§capacity: usize§max_weight: f32Implementations§
Source§impl Inventory
impl Inventory
pub fn new(capacity: usize, max_weight: f32) -> Self
pub fn add_item(&mut self, item: Item) -> Result<usize, Item>
pub fn remove_item(&mut self, slot: usize) -> Option<Item>
pub fn get(&self, slot: usize) -> Option<&Item>
pub fn current_weight(&self) -> f32
pub fn is_full(&self) -> bool
pub fn free_slots(&self) -> usize
pub fn item_count(&self) -> usize
pub fn find_by_id(&self, id: u64) -> Option<(usize, &Item)>
pub fn find_all_by_id(&self, id: u64) -> Vec<usize>
Sourcepub fn stack_items(&mut self)
pub fn stack_items(&mut self)
Try to stack all stackable items together
pub fn total_value(&self) -> u32
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inventory
impl RefUnwindSafe for Inventory
impl Send for Inventory
impl Sync for Inventory
impl Unpin for Inventory
impl UnsafeUnpin for Inventory
impl UnwindSafe for Inventory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more