Simplified miscellaneous Rust code, due to clippy linting.

pull/69/head
Project Nayuki 5 years ago
parent 78ee34f9a6
commit 621a77757e

@ -66,13 +66,12 @@ fn main() {
assert!(boostecl >> 1 == 0);
// Make segments for encoding
let segs: Vec<QrSegment>;
if isascii {
let segs: Vec<QrSegment> = if isascii {
let chrs: Vec<char> = std::str::from_utf8(&data).unwrap().chars().collect();
segs = QrSegment::make_segments(&chrs);
QrSegment::make_segments(&chrs)
} else {
segs = vec![QrSegment::make_bytes(&data)];
}
vec![QrSegment::make_bytes(&data)]
};
// Try to make QR Code symbol
let msk = if mask == -1 { None } else { Some(Mask::new(mask as u8)) };

@ -834,8 +834,8 @@ impl QrCode {
let n = runhistory[1];
assert!(n <= self.size * 3);
let core = n > 0 && runhistory[2] == n && runhistory[3] == n * 3 && runhistory[4] == n && runhistory[5] == n;
return if core && runhistory[0] >= n * 4 && runhistory[6] >= n { 1 } else { 0 }
+ if core && runhistory[6] >= n * 4 && runhistory[0] >= n { 1 } else { 0 };
( i32::from(core && runhistory[0] >= n * 4 && runhistory[6] >= n)
+ i32::from(core && runhistory[6] >= n * 4 && runhistory[0] >= n))
}
@ -1088,11 +1088,7 @@ impl QrSegment {
/// The character count (numchars) must agree with the mode and
/// the bit buffer length, but the constraint isn't checked.
pub fn new(mode: QrSegmentMode, numchars: usize, data: Vec<bool>) -> Self {
Self {
mode: mode,
numchars: numchars,
data: data,
}
Self { mode, numchars, data }
}

Loading…
Cancel
Save