summaryrefslogtreecommitdiff
path: root/src/storage.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage.rs')
-rw-r--r--src/storage.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/storage.rs b/src/storage.rs
index 00dca8b..3e900b2 100644
--- a/src/storage.rs
+++ b/src/storage.rs
@@ -13,4 +13,15 @@ impl Storage {
capacity : 100,
}
}
+
+ pub fn take(&mut self, name : &str) -> Option<Item> {
+ match self.items.iter().position(|item| item.name == name) {
+ Some(index) => Some(self.items.remove(index)),
+ None => None,
+ }
+ }
+
+ pub fn give(&mut self, item : Item) {
+ self.items.push(item);
+ }
}