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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.