From cd4718f8c50ae80ca0e87f89ebe7b96494b347ef Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Mon, 16 Aug 2021 21:08:39 +0100 Subject: [PATCH] Remove the need for this to be mut and write it in a more 'rusty' way --- agb/src/agb_alloc/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agb/src/agb_alloc/mod.rs b/agb/src/agb_alloc/mod.rs index 35e3f496..3833b27b 100644 --- a/agb/src/agb_alloc/mod.rs +++ b/agb/src/agb_alloc/mod.rs @@ -28,11 +28,11 @@ impl BumpAllocator { fn alloc_safe(&self, layout: Layout) -> *mut u8 { let mut current_ptr = self.current_ptr.lock(); - let mut ptr = *current_ptr as usize; - - if ptr == 0 { - ptr = get_data_end(); - } + let ptr = if current_ptr.is_null() { + get_data_end() + } else { + *current_ptr as usize + }; let alignment_bitmask = layout.align() - 1; let fixup = ptr & alignment_bitmask;