Skip to content

Commit 9ffc576

Browse files
committed
cargo fmt
1 parent e024573 commit 9ffc576

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

src/common/bit_matrix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl BitMatrix {
266266
pub fn set_bool(&mut self, x: u32, y: u32, value: bool) {
267267
if value {
268268
self.set(x, y)
269-
}else {
269+
} else {
270270
self.unset(x, y)
271271
}
272272
}

src/common/eci_string_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl ECIStringBuilder {
106106
pub fn appendECI(&mut self, value: u32) -> Result<(), Exceptions> {
107107
self.encodeCurrentBytesIfAny();
108108
let character_set_eci = CharacterSetECI::getCharacterSetECIByValue(value)?;
109-
109+
110110
self.current_charset = CharacterSetECI::getCharset(&character_set_eci);
111111
Ok(())
112112
}

src/datamatrix/decoder/datamatrix_decoder.rs

+26-15
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,28 @@ impl Decoder {
5252
pub fn decode(&self, bits: &BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
5353
let decoded = self.perform_decode(bits, false);
5454
if decoded.is_ok() {
55-
return decoded
55+
return decoded;
5656
}
5757

58-
self.perform_decode(&Self::flip_bitmatrix(bits)?, false)
58+
self.perform_decode(&Self::flip_bitmatrix(bits)?, false)
5959
}
6060

61-
fn flip_bitmatrix( bits:&BitMatrix) -> Result<BitMatrix,Exceptions>
62-
{
63-
let mut res = BitMatrix::new(bits.getHeight(), bits.getWidth())?;
64-
for y in 0..res.getHeight() {
65-
for x in 0..res.getWidth() {
66-
{res.set_bool(x, y, bits.get(bits.getWidth() - 1 - y, bits.getHeight() - 1 - x));}}}
67-
68-
Ok(res)
69-
}
61+
fn flip_bitmatrix(bits: &BitMatrix) -> Result<BitMatrix, Exceptions> {
62+
let mut res = BitMatrix::new(bits.getHeight(), bits.getWidth())?;
63+
for y in 0..res.getHeight() {
64+
for x in 0..res.getWidth() {
65+
{
66+
res.set_bool(
67+
x,
68+
y,
69+
bits.get(bits.getWidth() - 1 - y, bits.getHeight() - 1 - x),
70+
);
71+
}
72+
}
73+
}
74+
75+
Ok(res)
76+
}
7077

7178
/**
7279
* <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
@@ -78,7 +85,7 @@ impl Decoder {
7885
* @throws ChecksumException if error correction fails
7986
*/
8087
pub fn decode_bools(&self, image: &Vec<Vec<bool>>) -> Result<DecoderRXingResult, Exceptions> {
81-
self.perform_decode(&BitMatrix::parse_bools(image),false)
88+
self.perform_decode(&BitMatrix::parse_bools(image), false)
8289
}
8390

8491
/**
@@ -90,7 +97,11 @@ impl Decoder {
9097
* @throws FormatException if the Data Matrix Code cannot be decoded
9198
* @throws ChecksumException if error correction fails
9299
*/
93-
fn perform_decode(&self, bits: &BitMatrix, fix259: bool) -> Result<DecoderRXingResult, Exceptions> {
100+
fn perform_decode(
101+
&self,
102+
bits: &BitMatrix,
103+
fix259: bool,
104+
) -> Result<DecoderRXingResult, Exceptions> {
94105
// Construct a parser and read version, error-correction level
95106
let mut parser = BitMatrixParser::new(bits)?;
96107

@@ -119,8 +130,8 @@ impl Decoder {
119130
let errors_corrected = self.correctErrors(&mut codewordBytes, numDataCodewords as u32);
120131
if errors_corrected.is_err() && !fix259 {
121132
return self.perform_decode(bits, true);
122-
}else if errors_corrected.is_err() {
123-
return Err(errors_corrected.err().unwrap())
133+
} else if errors_corrected.is_err() {
134+
return Err(errors_corrected.err().unwrap());
124135
}
125136
for i in 0..numDataCodewords {
126137
// for (int i = 0; i < numDataCodewords; i++) {

src/datamatrix/decoder/decoded_bit_stream_parser.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,7 @@ fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Resu
693693

694694
let thirdByte = bits.readBits(8)?;
695695

696-
result
697-
.appendECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1)
696+
result.appendECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1)
698697

699698
// if bits.available() < 8 {
700699
// return Err(Exceptions::FormatException(None));

0 commit comments

Comments
 (0)