From 98540764ce7da535e1ee9ad3b72ad49d5c4c5ec0 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Mon, 28 Aug 2017 00:57:53 +0000 Subject: [PATCH] Simplified Rust code, without changing behavior. --- rust/src/lib.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 5a89dca..8287a7b 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -76,7 +76,7 @@ impl QrCode { // Find the minimal version number to use let mut version: u8 = minversion; - let mut datausedbits: usize; + let datausedbits: usize; loop { let datacapacitybits: usize = QrCode::get_num_data_codewords(version, ecl) * 8; // Number of data bits available if let Some(n) = QrSegment::get_total_bits(segs, version) { @@ -121,7 +121,7 @@ impl QrCode { } assert_eq!(bb.len() % 8, 0, "Assertion error"); - let mut bytes: Vec = vec![0; (bb.len() + 7) / 8]; + let mut bytes: Vec = vec![0; bb.len() / 8]; for (i, bit) in bb.iter().enumerate() { bytes[i >> 3] |= (*bit as u8) << (7 - (i & 7)); } @@ -983,9 +983,3 @@ pub fn append_bits(bb: &mut Vec, val: u32, len: u8) { bb.push((val >> i) & 1 != 0); } } - - -// Appends the data of the given segment to this bit buffer. -fn append_data(bb: &mut Vec, seg: &QrSegment) { - bb.extend_from_slice(&seg.data); -}