This commit is contained in:
kennytm 2015-03-04 05:17:12 +08:00
parent da775325ed
commit f68ad4a21a
2 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@
name = "qrcode" name = "qrcode"
description = "QR code encoder in Rust" description = "QR code encoder in Rust"
license = "Apache-2.0" license = "Apache-2.0"
version = "0.1.1" version = "0.1.2"
authors = ["kennytm <kennytm@gmail.com>"] authors = ["kennytm <kennytm@gmail.com>"]
keywords = ["qrcode"] keywords = ["qrcode"]
repository = "https://github.com/kennytm/qrcode-rust" repository = "https://github.com/kennytm/qrcode-rust"

View file

@ -1588,7 +1588,7 @@ impl Canvas {
let mut total_score = 0; let mut total_score = 0;
for i in 0 .. self.width { for i in 0 .. self.width {
let map_fn = |&:j| if is_horizontal { let map_fn = |j| if is_horizontal {
self.get(j, i) self.get(j, i)
} else { } else {
self.get(i, j) self.get(i, j)
@ -1655,16 +1655,16 @@ impl Canvas {
for j in 0 .. self.width-6 { for j in 0 .. self.width-6 {
// TODO a ref to a closure should be enough? // TODO a ref to a closure should be enough?
let get: Box<Fn(i16) -> Module> = if is_horizontal { let get: Box<Fn(i16) -> Module> = if is_horizontal {
Box::new(|&: k: i16| self.get(k, i)) Box::new(|k: i16| self.get(k, i))
} else { } else {
Box::new(|&: k: i16| self.get(i, k)) Box::new(|k: i16| self.get(i, k))
}; };
if !equals((j .. j+7).map(|k| get(k)), PATTERN.iter().map(|m| *m)) { if !equals((j .. j+7).map(|k| get(k)), PATTERN.iter().map(|m| *m)) {
continue; continue;
} }
let check = |&: k| { 0 <= k && k < self.width && get(k).is_dark() }; let check = |k| { 0 <= k && k < self.width && get(k).is_dark() };
if !(j-4 .. j).any(|k| check(k)) || !(j+7 .. j+11).any(|k| check(k)) { if !(j-4 .. j).any(|k| check(k)) || !(j+7 .. j+11).any(|k| check(k)) {
total_score += 40; total_score += 40;
} }