This commit is contained in:
kennytm 2014-12-26 05:28:30 +08:00
parent 23c2284f09
commit d983500a58
5 changed files with 14 additions and 13 deletions

View file

@ -142,6 +142,7 @@ fn bench_push_splitted_bytes(bencher: &mut Bencher) {
/// An "extended" mode indicator, includes all indicators supported by QR code
/// beyond those bearing data.
#[deriving(Copy)]
pub enum ExtendedMode {
/// ECI mode indicator, to introduce an ECI designator.
Eci,

View file

@ -1276,7 +1276,7 @@ mod draw_codewords_test {
/// The mask patterns. Since QR code and Micro QR code do not use the same
/// pattern number, we name them according to their shape instead of the number.
#[deriving(Show)]
#[deriving(Show, Copy)]
pub enum MaskPattern {
/// QR code pattern 000: `(x + y) % 2 == 0`.
Checkerboard = 0b000,
@ -1492,10 +1492,10 @@ impl Canvas {
let mut total_score = 0;
for i in range(0, self.width) {
let map_fn = if is_horizontal {
|j| self.get(j, i)
let map_fn = |&:j| if is_horizontal {
self.get(j, i)
} else {
|j| self.get(i, j)
self.get(i, j)
};
let mut colors = range(0, self.width).map(map_fn)

View file

@ -20,7 +20,6 @@
#![unstable]
#![feature(slicing_syntax)]
#![feature(while_let)]
extern crate test;

View file

@ -1,19 +1,17 @@
#![unstable]
//! Find the optimal data mode sequence to encode a piece of data.
use std::slice::Items;
use std::slice::Iter;
use types::{Mode, Version};
#[cfg(test)]
use test::Bencher;
use types::{Mode, Version};
//------------------------------------------------------------------------------
//{{{ Segment
/// A segment of data committed to an encoding mode.
#[deriving(PartialEq, Eq, Show)]
#[deriving(PartialEq, Eq, Show, Copy, Clone)]
pub struct Segment {
/// The encoding mode of the segment of data.
pub mode: Mode,
@ -82,7 +80,7 @@ impl<'a, I: Iterator<&'a u8>> Iterator<(uint, ExclCharSet)> for EcsIter<I> {
/// QR code data parser to classify the input into distinct segments.
pub struct Parser<'a> {
ecs_iter: EcsIter<Items<'a, u8>>,
ecs_iter: EcsIter<Iter<'a, u8>>,
state: State,
begin: uint,
pending_single_byte: bool,
@ -467,6 +465,7 @@ fn bench_optimize(bencher: &mut Bencher) {
/// All values of `u8` can be split into 9 different character sets when
/// determining which encoding to use. This enum represents these groupings for
/// parsing purpose.
#[deriving(Copy)]
enum ExclCharSet {
/// The end of string.
End = 0,
@ -526,6 +525,7 @@ impl ExclCharSet {
}
/// The current parsing state.
#[deriving(Copy)]
enum State {
/// Just initialized.
Init = 0,
@ -552,6 +552,7 @@ enum State {
}
/// What should the parser do after a state transition.
#[deriving(Copy)]
enum Action {
/// The parser should do nothing.
Idle,

View file

@ -7,7 +7,7 @@ use std::default::Default;
/// `QrError` encodes the error encountered when generating a QR code.
#[unstable]
#[deriving(Show, PartialEq, Eq)]
#[deriving(Show, PartialEq, Eq, Copy, Clone)]
pub enum QrError {
/// The data is too long to encode into a QR code for the given version.
DataTooLong,
@ -136,7 +136,7 @@ impl Version {
/// The mode indicator, which specifies the character set of the encoded data.
#[unstable]
#[deriving(Show, PartialEq, Eq)]
#[deriving(Show, PartialEq, Eq, Copy, Clone)]
pub enum Mode {
/// The data contains only characters 0 to 9.
Numeric,