Skip to content

Commit 7c9303d

Browse files
committed
refactor: use ok_or
1 parent b36f8bb commit 7c9303d

File tree

1 file changed

+3
-4
lines changed
  • crates/hyperion-inventory/src

1 file changed

+3
-4
lines changed

crates/hyperion-inventory/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,9 @@ impl Inventory {
326326
&mut self,
327327
index: u16,
328328
) -> Result<&mut ItemSlot, InventoryAccessError> {
329-
match self.slots.get_mut(usize::from(index)) {
330-
Some(slot) => Ok(slot),
331-
None => Err(InventoryAccessError::InvalidSlot { index }),
332-
}
329+
self.slots
330+
.get_mut(usize::from(index))
331+
.ok_or(InventoryAccessError::InvalidSlot { index })
333332
}
334333

335334
/// Returns remaining [`ItemStack`] if not all of the item was added to the slot

0 commit comments

Comments
 (0)