diff --git a/src/common/BitMatrixTestCase.rs b/src/common/BitMatrixTestCase.rs index 1a3ac71..4408b56 100644 --- a/src/common/BitMatrixTestCase.rs +++ b/src/common/BitMatrixTestCase.rs @@ -151,17 +151,17 @@ fn test_get_row() { } // Should allocate - let array = matrix.getRow(2, &BitArray::new()); + let array = matrix.getRow(2, BitArray::new()); assert_eq!(102, array.getSize()); // Should reallocate let mut array2 = BitArray::with_size(60); - array2 = matrix.getRow(2, &array2); + array2 = matrix.getRow(2, array2); assert_eq!(102, array2.getSize()); // Should use provided object, with original BitArray size let mut array3 = BitArray::with_size(200); - array3 = matrix.getRow(2, &array3); + array3 = matrix.getRow(2, array3); assert_eq!(200, array3.getSize()); for x in 0..102 { diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index d7a53e0..d49b6d7 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -254,12 +254,12 @@ impl BitMatrix { "input matrix dimensions do not match".to_owned(), )); } - let rowArray = BitArray::with_size(self.width as usize); + let mut rowArray = BitArray::with_size(self.width as usize); for y in 0..self.height { //for (int y = 0; y < height; y++) { let offset = y as usize * self.row_size; - let tmp = mask.getRow(y, &rowArray); - let row = tmp.getBitArray(); + rowArray = mask.getRow(y, rowArray); + let row = rowArray.getBitArray(); for x in 0..self.row_size { //for (int x = 0; x < rowSize; x++) { self.bits[offset + x] ^= row[x]; @@ -330,11 +330,11 @@ impl BitMatrix { * @return The resulting BitArray - this reference should always be used even when passing * your own row */ - pub fn getRow(&self, y: u32, row: &BitArray) -> BitArray { + pub fn getRow(&self, y: u32, row: BitArray) -> BitArray { let mut rw: BitArray = if row.getSize() < self.width as usize { BitArray::with_size(self.width as usize) } else { - let mut z = row.clone(); + let mut z = row; //row.clone(); z.clear(); z // row.clear(); @@ -395,9 +395,9 @@ impl BitMatrix { let maxHeight = (self.height + 1) / 2; for i in 0..maxHeight { //for (int i = 0; i < maxHeight; i++) { - topRow = self.getRow(i, &topRow); + topRow = self.getRow(i, topRow); let bottomRowIndex = self.height - 1 - i; - bottomRow = self.getRow(bottomRowIndex, &bottomRow); + bottomRow = self.getRow(bottomRowIndex, bottomRow); topRow.reverse(); bottomRow.reverse(); self.setRow(i, &bottomRow); diff --git a/src/oned/code_39_reader.rs b/src/oned/code_39_reader.rs index 14795c9..27976b5 100644 --- a/src/oned/code_39_reader.rs +++ b/src/oned/code_39_reader.rs @@ -412,7 +412,7 @@ mod code_39_extended_mode_test_case { let matrix = BitMatrix::parse_strings(encodedRXingResult, "1", "0").expect("bitmatrix parse"); let row = BitArray::with_size(matrix.getWidth() as usize); - let row = matrix.getRow(0, &row); + let row = matrix.getRow(0, row); let result = sut.decodeRow(0, &row, &HashMap::new()).expect("decode row"); assert_eq!(expectedRXingResult, result.getText()); }