rustup
This commit is contained in:
parent
23c2284f09
commit
d983500a58
|
@ -142,6 +142,7 @@ fn bench_push_splitted_bytes(bencher: &mut Bencher) {
|
||||||
|
|
||||||
/// An "extended" mode indicator, includes all indicators supported by QR code
|
/// An "extended" mode indicator, includes all indicators supported by QR code
|
||||||
/// beyond those bearing data.
|
/// beyond those bearing data.
|
||||||
|
#[deriving(Copy)]
|
||||||
pub enum ExtendedMode {
|
pub enum ExtendedMode {
|
||||||
/// ECI mode indicator, to introduce an ECI designator.
|
/// ECI mode indicator, to introduce an ECI designator.
|
||||||
Eci,
|
Eci,
|
||||||
|
|
|
@ -1276,7 +1276,7 @@ mod draw_codewords_test {
|
||||||
|
|
||||||
/// The mask patterns. Since QR code and Micro QR code do not use the same
|
/// 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.
|
/// pattern number, we name them according to their shape instead of the number.
|
||||||
#[deriving(Show)]
|
#[deriving(Show, Copy)]
|
||||||
pub enum MaskPattern {
|
pub enum MaskPattern {
|
||||||
/// QR code pattern 000: `(x + y) % 2 == 0`.
|
/// QR code pattern 000: `(x + y) % 2 == 0`.
|
||||||
Checkerboard = 0b000,
|
Checkerboard = 0b000,
|
||||||
|
@ -1492,10 +1492,10 @@ impl Canvas {
|
||||||
let mut total_score = 0;
|
let mut total_score = 0;
|
||||||
|
|
||||||
for i in range(0, self.width) {
|
for i in range(0, self.width) {
|
||||||
let map_fn = if is_horizontal {
|
let map_fn = |&:j| if is_horizontal {
|
||||||
|j| self.get(j, i)
|
self.get(j, i)
|
||||||
} else {
|
} else {
|
||||||
|j| self.get(i, j)
|
self.get(i, j)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut colors = range(0, self.width).map(map_fn)
|
let mut colors = range(0, self.width).map(map_fn)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#![unstable]
|
#![unstable]
|
||||||
#![feature(slicing_syntax)]
|
#![feature(slicing_syntax)]
|
||||||
#![feature(while_let)]
|
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#![unstable]
|
#![unstable]
|
||||||
|
|
||||||
//! Find the optimal data mode sequence to encode a piece of data.
|
//! Find the optimal data mode sequence to encode a piece of data.
|
||||||
|
use std::slice::Iter;
|
||||||
use std::slice::Items;
|
use types::{Mode, Version};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
use types::{Mode, Version};
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
//{{{ Segment
|
//{{{ Segment
|
||||||
|
|
||||||
/// A segment of data committed to an encoding mode.
|
/// A segment of data committed to an encoding mode.
|
||||||
#[deriving(PartialEq, Eq, Show)]
|
#[deriving(PartialEq, Eq, Show, Copy, Clone)]
|
||||||
pub struct Segment {
|
pub struct Segment {
|
||||||
/// The encoding mode of the segment of data.
|
/// The encoding mode of the segment of data.
|
||||||
pub mode: Mode,
|
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.
|
/// QR code data parser to classify the input into distinct segments.
|
||||||
pub struct Parser<'a> {
|
pub struct Parser<'a> {
|
||||||
ecs_iter: EcsIter<Items<'a, u8>>,
|
ecs_iter: EcsIter<Iter<'a, u8>>,
|
||||||
state: State,
|
state: State,
|
||||||
begin: uint,
|
begin: uint,
|
||||||
pending_single_byte: bool,
|
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
|
/// All values of `u8` can be split into 9 different character sets when
|
||||||
/// determining which encoding to use. This enum represents these groupings for
|
/// determining which encoding to use. This enum represents these groupings for
|
||||||
/// parsing purpose.
|
/// parsing purpose.
|
||||||
|
#[deriving(Copy)]
|
||||||
enum ExclCharSet {
|
enum ExclCharSet {
|
||||||
/// The end of string.
|
/// The end of string.
|
||||||
End = 0,
|
End = 0,
|
||||||
|
@ -526,6 +525,7 @@ impl ExclCharSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The current parsing state.
|
/// The current parsing state.
|
||||||
|
#[deriving(Copy)]
|
||||||
enum State {
|
enum State {
|
||||||
/// Just initialized.
|
/// Just initialized.
|
||||||
Init = 0,
|
Init = 0,
|
||||||
|
@ -552,6 +552,7 @@ enum State {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What should the parser do after a state transition.
|
/// What should the parser do after a state transition.
|
||||||
|
#[deriving(Copy)]
|
||||||
enum Action {
|
enum Action {
|
||||||
/// The parser should do nothing.
|
/// The parser should do nothing.
|
||||||
Idle,
|
Idle,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::default::Default;
|
||||||
|
|
||||||
/// `QrError` encodes the error encountered when generating a QR code.
|
/// `QrError` encodes the error encountered when generating a QR code.
|
||||||
#[unstable]
|
#[unstable]
|
||||||
#[deriving(Show, PartialEq, Eq)]
|
#[deriving(Show, PartialEq, Eq, Copy, Clone)]
|
||||||
pub enum QrError {
|
pub enum QrError {
|
||||||
/// The data is too long to encode into a QR code for the given version.
|
/// The data is too long to encode into a QR code for the given version.
|
||||||
DataTooLong,
|
DataTooLong,
|
||||||
|
@ -136,7 +136,7 @@ impl Version {
|
||||||
|
|
||||||
/// The mode indicator, which specifies the character set of the encoded data.
|
/// The mode indicator, which specifies the character set of the encoded data.
|
||||||
#[unstable]
|
#[unstable]
|
||||||
#[deriving(Show, PartialEq, Eq)]
|
#[deriving(Show, PartialEq, Eq, Copy, Clone)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
/// The data contains only characters 0 to 9.
|
/// The data contains only characters 0 to 9.
|
||||||
Numeric,
|
Numeric,
|
||||||
|
|
Loading…
Reference in a new issue