summaryrefslogtreecommitdiff
path: root/src/storage.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-06-05 02:21:04 -0500
committertom barrett <spalf0@gmail.com>2018-06-05 02:21:04 -0500
commitf6c9fbea8f535febaf51dc08c353e985aa73988d (patch)
tree7168eeb42589b8e425b895a423fdcd4c83c64ae6 /src/storage.rs
parentd2b75c42c1c494c2796188a5d600dddb913f5a5d (diff)
frail implementation of mining
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);
+ }
}