From 98963e5cbaa8a643c484e9d3c18b9b0b86c6ef24 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Wed, 14 Oct 2020 01:27:54 +0000 Subject: [PATCH] Tweaked Rust code to narrow the bit width of QrCodeEcc.format_bits(). --- rust/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6a90c81..66d354c 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -438,7 +438,7 @@ impl QrCode { // Calculate error correction code and pack bits let bits: u32 = { // errcorrlvl is uint2, mask is uint3 - let data: u32 = self.errorcorrectionlevel.format_bits() << 3 | u32::from(mask.value()); + let data: u32 = u32::from(self.errorcorrectionlevel.format_bits() << 3 | mask.value()); let mut rem: u32 = data; for _ in 0 .. 10 { rem = (rem << 1) ^ ((rem >> 9) * 0x537); @@ -949,7 +949,7 @@ impl QrCodeEcc { // Returns an unsigned 2-bit integer (in the range 0 to 3). - fn format_bits(self) -> u32 { + fn format_bits(self) -> u8 { use QrCodeEcc::*; match self { Low => 1,