From 91fdbeac112ff32ed5d2cd478e4310667e9b8d61 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 1 Jan 2015 22:08:33 +0800 Subject: [PATCH] Retry doc upload; Kill some deprecated functions. --- .travis.yml | 1 + src/bits.rs | 5 +++-- src/canvas.rs | 4 ++-- src/ec.rs | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 705b1ca..b40b9f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ language: rust after_script: - cargo doc + - mv target/doc doc - curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh diff --git a/src/bits.rs b/src/bits.rs index a7a2a51..b92dda8 100644 --- a/src/bits.rs +++ b/src/bits.rs @@ -3,6 +3,7 @@ //! The `bits` module encodes binary data into raw bits used in a QR code. use std::cmp::min; +use std::iter::iterate; #[cfg(test)] use test::Bencher; @@ -678,8 +679,8 @@ impl Bits { self.bit_offset = 0; let data_bytes_length = data_length / 8; let padding_bytes_count = data_bytes_length - self.data.len(); - self.data.grow_fn(padding_bytes_count, - |i| if i % 2 == 0 { 0b11101100 } else { 0b00010001 }); + let padding = iterate(0b11101100, |a| a ^ 0b11111101).take(padding_bytes_count); + self.data.extend(padding); } if self.len() < data_length { diff --git a/src/canvas.rs b/src/canvas.rs index 7cb1782..bfce78b 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -9,7 +9,7 @@ //! c.apply_mask(MaskPattern::Checkerboard); //! let bools = c.to_bools(); -use std::iter::range_inclusive; +use std::iter::{range_inclusive, repeat}; use std::iter::order::equals; use std::num::Int; use std::cmp::max; @@ -102,7 +102,7 @@ impl Canvas { width: width, version: version, ec_level: ec_level, - modules: Vec::from_elem((width*width) as uint, Module::Empty), + modules: repeat(Module::Empty).take((width*width) as uint).collect() } } diff --git a/src/ec.rs b/src/ec.rs index 64530d6..865e353 100644 --- a/src/ec.rs +++ b/src/ec.rs @@ -1,5 +1,7 @@ //! The `ec` module applies the Reed-Solomon error correction codes. +use std::iter::repeat; + use types::{QrResult, Version, EcLevel}; //------------------------------------------------------------------------------ @@ -16,7 +18,7 @@ use types::{QrResult, Version, EcLevel}; /// polynomial of degree N. pub fn create_error_correction_code(data: &[u8], ec_code_size: uint) -> Vec { let mut res = data.to_vec(); - res.grow(ec_code_size, 0); + res.extend(repeat(0).take(ec_code_size)); let data_len = data.len(); let log_den = GENERATOR_POLYNOMIALS[ec_code_size];