diff options
author | tom barrett <spalf0@gmail.com> | 2018-06-26 04:41:55 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-06-26 04:41:55 -0500 |
commit | 2d01ede909281e8c412924ba524b7406c2d760ee (patch) | |
tree | 30ef26c641643251797e9d82115a40a9fe9a05ae /src | |
parent | 39b16e379fb679aa56ded8ab5463569e5633a656 (diff) |
-forgot when taking, reduce carrying
Diffstat (limited to 'src')
-rw-r--r-- | src/storage.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/storage.rs b/src/storage.rs index 3c6e684..5cae0ff 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -29,7 +29,11 @@ impl Storage { 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)), + Some(index) => { + let item = self.items.remove(index); + self.carrying -= item.size; + Some(item) + } None => None, } } |