diff --git a/src/bits.rs b/src/bits.rs index 2ad03c2..a7a2a51 100644 --- a/src/bits.rs +++ b/src/bits.rs @@ -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, diff --git a/src/canvas.rs b/src/canvas.rs index 632e034..71da3bc 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -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) diff --git a/src/lib.rs b/src/lib.rs index 5d1dde2..8e0218c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,6 @@ #![unstable] #![feature(slicing_syntax)] -#![feature(while_let)] extern crate test; diff --git a/src/optimize.rs b/src/optimize.rs index 1ac8997..57fc86d 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -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 { /// QR code data parser to classify the input into distinct segments. pub struct Parser<'a> { - ecs_iter: EcsIter>, + ecs_iter: EcsIter>, 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, diff --git a/src/types.rs b/src/types.rs index 6abf9c0..5d4f8f1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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,