From 2d01ede909281e8c412924ba524b7406c2d760ee Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 26 Jun 2018 04:41:55 -0500 Subject: -forgot when taking, reduce carrying --- src/storage.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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 { 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, } } -- cgit v1.2.3