From c65eadf1022fff0d3873ec251a5bbe6da76447e2 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Tue, 3 Jan 2023 11:56:21 -0600 Subject: [PATCH] cleanup bit_matrix --- src/common/bit_matrix.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index 5e917a2..6a6ea14 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -427,7 +427,7 @@ impl BitMatrix { let newWidth = self.height; let newHeight = self.width; let newRowSize = (newWidth + 31) / 32; - let mut newBits = vec![0; (newRowSize * newHeight).try_into().unwrap()]; + let mut newBits = vec![0; (newRowSize * newHeight) as usize]; for y in 0..self.height { //for (int y = 0; y < height; y++) { @@ -435,16 +435,14 @@ impl BitMatrix { //for (int x = 0; x < width; x++) { let offset = y as usize * self.row_size + (x as usize / 32); if ((self.bits[offset] >> (x & 0x1f)) & 1) != 0 { - let newOffset: usize = ((newHeight - 1 - x) * newRowSize + (y / 32)) - .try_into() - .unwrap(); + let newOffset: usize = ((newHeight - 1 - x) * newRowSize + (y / 32)) as usize; newBits[newOffset] |= 1 << (y & 0x1f); } } } self.width = newWidth; self.height = newHeight; - self.row_size = newRowSize.try_into().unwrap(); + self.row_size = newRowSize as usize; self.bits = newBits; }