mirror of
https://gitee.com/openharmony/third_party_qrcodegen
synced 2024-11-30 10:50:35 +00:00
Clarified a few pieces of Rust code.
This commit is contained in:
parent
d00cbd3585
commit
bafd258293
@ -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),
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user