diff --git a/rust/examples/qrcodegen-demo.rs b/rust/examples/qrcodegen-demo.rs index 80b2b7a..67665f8 100644 --- a/rust/examples/qrcodegen-demo.rs +++ b/rust/examples/qrcodegen-demo.rs @@ -128,8 +128,8 @@ fn do_segment_demo() { 0x0000, 0x0208, 0x01FF, 0x0008, ]; let mut bb = qrcodegen::BitBuffer(Vec::new()); - for c in &kanjichars { - bb.append_bits(*c, 13); + for &c in &kanjichars { + bb.append_bits(c, 13); } let segs = vec![ QrSegment::new(qrcodegen::QrSegmentMode::Kanji, kanjichars.len(), bb.0), diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 17da2fc..d342e32 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -296,7 +296,7 @@ impl QrCode { // Do masking if mask.is_none() { // Automatically choose best mask - let mut minpenalty: i32 = std::i32::MAX; + let mut minpenalty = std::i32::MAX; for i in 0u8 .. 8 { let newmask = Mask::new(i); result.apply_mask(newmask); @@ -617,10 +617,9 @@ impl QrCode { // the same mask value a second time will undo the mask. A final well-formed // QR Code needs exactly one (not zero, two, etc.) mask applied. fn apply_mask(&mut self, mask: Mask) { - let mask: u8 = mask.value(); for y in 0 .. self.size { for x in 0 .. self.size { - let invert: bool = match mask { + let invert: bool = match mask.value() { 0 => (x + y) % 2 == 0, 1 => y % 2 == 0, 2 => x % 3 == 0,