From f6c9fbea8f535febaf51dc08c353e985aa73988d Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 5 Jun 2018 02:21:04 -0500 Subject: frail implementation of mining --- src/storage.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/storage.rs') 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 { + 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); + } } -- cgit v1.2.3