mindustry logic execution, map- and schematic- parsing and rendering
Make registering blocks return a reference
| -rw-r--r-- | src/block/mod.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/block/mod.rs b/src/block/mod.rs index f3b3e82..074e431 100644 --- a/src/block/mod.rs +++ b/src/block/mod.rs @@ -150,7 +150,7 @@ impl<'l> BlockRegistry<'l> Self{blocks: HashMap::new()} } - pub fn register(&mut self, block: &'l Block) -> Result<(), &'l Block> + pub fn register(&mut self, block: &'l Block) -> Result<&'l Block, &'l Block> { let key = match block.name { @@ -160,11 +160,7 @@ impl<'l> BlockRegistry<'l> match self.blocks.entry(key) { Entry::Occupied(e) => Err(e.get()), - Entry::Vacant(e) => - { - e.insert(block); - Ok(()) - }, + Entry::Vacant(e) => Ok(*e.insert(block)), } } |