Debian Codegraph @

src/optimize.rs

raw symbols SCIP
1 //! Find the optimal data mode sequence to encode a piece of data.
2 use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Moderust-analyzer cargo qrcode 0.14.1 types/Mode#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#};
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#;
4
5 #[cfg(feature = "bench")]
6 extern crate testrust-analyzer cargo qrcode 0.14.1 optimize/test/;
7
8 //------------------------------------------------------------------------------
9 //{{{ Segment
10
11 /// A segment of data committed to an encoding mode.
12 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
13 pub struct Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# {
14 /// The encoding mode of the segment of data.
15 pub moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#,
16
17 /// The start index of the segment.
18 pub beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: usize,
19
20 /// The end index (exclusive) of the segment.
21 pub endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: usize,
22 }
23
24 impl Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# {
25 /// Compute the number of bits (including the size of the mode indicator and
26 /// length bits) when this segment is encoded.
27 pub fn encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/impl#[Segment]encoded_len().(&self, version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) -> usize {
28 let byte_size = self.endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.;
29 let chars_count = if self.moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode. rust-analyzer cargo qrcode 0.14.1 types/impl#[Mode][`PartialEq<Self>`]eq().==rust-analyzer cargo qrcode 0.14.1 types/impl#[Mode][`PartialEq<Self>`]eq(). rust-analyzer cargo qrcode 0.14.1 types/impl#[Mode][`PartialEq<Self>`]eq().Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji# { byte_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2 } else { byte_size };
30
31 let mode_bits_count = version.mode_bits_countrust-analyzer cargo qrcode 0.14.1 types/impl#[Version]mode_bits_count().();
32 let length_bits_count = self.moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode..length_bits_countrust-analyzer cargo qrcode 0.14.1 types/impl#[Mode]length_bits_count().(version);
33 let data_bits_count = self.moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode..data_bits_countrust-analyzer cargo qrcode 0.14.1 types/impl#[Mode]data_bits_count().(chars_count);
34
35 mode_bits_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().length_bits_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().data_bits_count
36 }
37 }
38
39 //}}}
40 //------------------------------------------------------------------------------
41 //{{{ Parser
42
43 /// This iterator is basically equivalent to
44 ///
45 /// ```ignore
46 /// data.map(|c| ExclCharSet::from_u8(*c))
47 /// .chain(Some(ExclCharSet::End).move_iter())
48 /// .enumerate()
49 /// ```
50 ///
51 /// But the type is too hard to write, thus the new type.
52 ///
53 struct EcsIterrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#<I> {
54 baserust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#base.: I,
55 indexrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#index.: usize,
56 endedrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#ended.: bool,
57 }
58
59 impl<'a, I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'a u8>> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for EcsIterrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#<I> {
60 type Itemrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`EcsIter<I>`][Iterator]Item# = (usize, ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#);
61
62 fn nextrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`EcsIter<I>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#)> {
63 if self.endedrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#ended. {
64 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
65 }
66
67 match self.baserust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#base..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().() {
68 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
69 self.endedrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#ended. = true;
70 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((self.indexrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#index., ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::Endrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#End#))
71 }
72 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) => {
73 let old_index = self.indexrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#index.;
74 self.indexrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
75 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((old_index, ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::from_u8rust-analyzer cargo qrcode 0.14.1 optimize/impl#[ExclCharSet]from_u8().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c)))
76 }
77 }
78 }
79 }
80
81 /// QR code data parser to classify the input into distinct segments.
82 pub struct Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#<'a> {
83 ecs_iterrust-analyzer cargo qrcode 0.14.1 optimize/Parser#ecs_iter.: EcsIterrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#<Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, u8>>,
84 staterust-analyzer cargo qrcode 0.14.1 optimize/Parser#state.: Staterust-analyzer cargo qrcode 0.14.1 optimize/State#,
85 beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin.: usize,
86 pending_single_byterust-analyzer cargo qrcode 0.14.1 optimize/Parser#pending_single_byte.: bool,
87 }
88
89 impl<'a> Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#<'a> {
90 /// Creates a new iterator which parse the data into segments that only
91 /// contains their exclusive subsets. No optimization is done at this point.
92 ///
93 /// use qrcode::optimize::{Parser, Segment};
94 /// use qrcode::types::Mode::{Alphanumeric, Numeric, Byte};
95 ///
96 /// let parse_res = Parser::new(b"ABC123abcd").collect::<Vec<Segment>>();
97 /// assert_eq!(parse_res, vec![Segment { mode: Alphanumeric, begin: 0, end: 3 },
98 /// Segment { mode: Numeric, begin: 3, end: 6 },
99 /// Segment { mode: Byte, begin: 6, end: 10 }]);
100 ///
101 pub fn newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`]new().(data: &[u8]) -> Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser# {
102 Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser# {
103 ecs_iterrust-analyzer cargo qrcode 0.14.1 optimize/Parser#ecs_iter.: EcsIterrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter# { baserust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#base.: data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), indexrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#index.: 0, endedrust-analyzer cargo qrcode 0.14.1 optimize/EcsIter#ended.: false },
104 staterust-analyzer cargo qrcode 0.14.1 optimize/Parser#state.: Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#,
105 beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin.: 0,
106 pending_single_byterust-analyzer cargo qrcode 0.14.1 optimize/Parser#pending_single_byte.: false,
107 }
108 }
109 }
110
111 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#<'a> {
112 type Itemrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`][Iterator]Item# = Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#;
113
114 fn nextrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#> {
115 if self.pending_single_byterust-analyzer cargo qrcode 0.14.1 optimize/Parser#pending_single_byte. {
116 self.pending_single_byterust-analyzer cargo qrcode 0.14.1 optimize/Parser#pending_single_byte. = false;
117 self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
118 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. });
119 }
120
121 loop {
122 let (i, ecs) = match self.ecs_iterrust-analyzer cargo qrcode 0.14.1 optimize/Parser#ecs_iter..nextrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`EcsIter<I>`][Iterator]next().() {
123 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
124 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(a) => a,
125 };
126 let (next_state, action) = STATE_TRANSITIONrust-analyzer cargo qrcode 0.14.1 optimize/STATE_TRANSITION.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().self.staterust-analyzer cargo qrcode 0.14.1 optimize/Parser#state. as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().ecs as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
127 self.staterust-analyzer cargo qrcode 0.14.1 optimize/Parser#state. = next_state;
128
129 let old_begin = self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin.;
130 let push_mode = match action {
131 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle# => continue,
132 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric# => Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#,
133 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha# => Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#,
134 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte# => Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#,
135 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji# => Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#,
136 Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte# => {
137 let next_begin = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
138 if self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().next_begin {
139 Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#
140 } else {
141 self.pending_single_byterust-analyzer cargo qrcode 0.14.1 optimize/Parser#pending_single_byte. = true;
142 self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. = next_begin;
143 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: old_begin, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: next_begin });
144 }
145 }
146 };
147
148 self.beginrust-analyzer cargo qrcode 0.14.1 optimize/Parser#begin. = i;
149 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: push_mode, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: old_begin, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: i });
150 }
151 }
152 }
153
154 #[cfg(test)]
155 mod parse_testsrust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/ {
156 use craterust-analyzer cargo qrcode 0.14.1 crate/::optimizerust-analyzer cargo qrcode 0.14.1 optimize/::{Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#};
157 use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::Moderust-analyzer cargo qrcode 0.14.1 types/Mode#;
158
159 fn parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(data: &[u8]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#> {
160 Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#::newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`]new().(data).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
161 }
162
163 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
164 fn test_parse_1rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_parse_1().() {
165 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"01049123451234591597033130128%10ABC123");
166 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
167 segs,
168 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
169 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 29 },
170 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 29, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 30 },
171 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 30, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 32 },
172 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 32, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 35 },
173 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 35, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 38 },
174 ]
175 );
176 }
177
178 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
179 fn test_parse_shift_jis_example_1rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_parse_shift_jis_example_1().() {
180 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\x82\xa0\x81\x41\x41\xb1\x81\xf0"); // "あ、AアÅ"
181 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
182 segs,
183 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
184 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
185 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 4, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 5 },
186 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 5, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 6 },
187 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 6, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 8 },
188 ]
189 );
190 }
191
192 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
193 fn test_parse_utf_8rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_parse_utf_8().() {
194 // Mojibake?
195 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\xe3\x81\x82\xe3\x80\x81A\xef\xbd\xb1\xe2\x84\xab");
196 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
197 segs,
198 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
199 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
200 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 4, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 5 },
201 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 5, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 7 },
202 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 7, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 10 },
203 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 10, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 12 },
204 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 12, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 13 },
205 ]
206 );
207 }
208
209 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
210 fn test_not_kanji_1rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_not_kanji_1().() {
211 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\x81\x30");
212 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
213 segs,
214 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 1 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 1, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 2 },]
215 );
216 }
217
218 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
219 fn test_not_kanji_2rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_not_kanji_2().() {
220 // Note that it's implementation detail that the byte seq is split into
221 // two. Perhaps adjust the test to check for this.
222 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\xeb\xc0");
223 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
224 segs,
225 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 1 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 1, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 2 },]
226 );
227 }
228
229 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
230 fn test_not_kanji_3rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_not_kanji_3().() {
231 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\x81\x7f");
232 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
233 segs,
234 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 1 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 1, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 2 },]
235 );
236 }
237
238 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
239 fn test_not_kanji_4rust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/test_not_kanji_4().() {
240 let segs = parserust-analyzer cargo qrcode 0.14.1 optimize/parse_tests/parse().(b"\x81\x40\x81");
241 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
242 segs,
243 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 2 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 2, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 3 },]
244 );
245 }
246 }
247
248 //}}}
249 //------------------------------------------------------------------------------
250 //{{{ Optimizer
251
252 pub struct Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#<I> {
253 parserrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#parser.: I,
254 last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment.: Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#,
255 last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size.: usize,
256 versionrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#version.: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#,
257 endedrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#ended.: bool,
258 }
259
260 impl<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#>> Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#<I> {
261 /// Optimize the segments by combining adjacent segments when possible.
262 ///
263 /// Currently this method uses a greedy algorithm by combining segments from
264 /// left to right until the new segment is longer than before. This method
265 /// does *not* use Annex J from the ISO standard.
266 ///
267 pub fn newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`]new().(mut segments: I, version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) -> Selfrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`] {
268 match segments.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().() {
269 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Selfrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`] {
270 parserrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#parser.: segments,
271 last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment.: Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 0 },
272 last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size.: 0,
273 versionrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#version.,
274 endedrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#ended.: true,
275 },
276 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(segment) => Selfrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`] {
277 parserrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#parser.: segments,
278 last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment.: segment,
279 last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size.: segment.encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/impl#[Segment]encoded_len().(version),
280 versionrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#version.,
281 endedrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#ended.: false,
282 },
283 }
284 }
285 }
286
287 impl<'a> Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#<'a> {
288 pub fn optimizerust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`]optimize().(self, version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) -> Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#<Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#<'a>> {
289 Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#::newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`]new().(self, version)
290 }
291 }
292
293 impl<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#>> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#<I> {
294 type Itemrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`][Iterator]Item# = Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#;
295
296 fn nextrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#> {
297 if self.endedrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#ended. {
298 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
299 }
300
301 loop {
302 match self.parserrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#parser..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().() {
303 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
304 self.endedrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#ended. = true;
305 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment.);
306 }
307 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(segment) => {
308 let seg_size = segment.encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/impl#[Segment]encoded_len().(self.versionrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#version.);
309
310 let new_segment = Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# {
311 moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment..moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode..maxrust-analyzer cargo qrcode 0.14.1 types/impl#[Mode]max().(segment.moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.),
312 beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment..beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.,
313 endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: segment.endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.,
314 };
315 let new_size = new_segment.encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/impl#[Segment]encoded_len().(self.versionrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#version.);
316
317 if self.last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().seg_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().new_size {
318 self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment. = new_segment;
319 self.last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size. = new_size;
320 } else {
321 let old_segment = self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment.;
322 self.last_segmentrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment. = segment;
323 self.last_segment_sizerust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#last_segment_size. = seg_size;
324 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(old_segment);
325 }
326 }
327 }
328 }
329 }
330 }
331
332 /// Computes the total encoded length of all segments.
333 pub fn total_encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/total_encoded_len().(segments: &[Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#], version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) -> usize {
334 segments.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|seg| seg.encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/impl#[Segment]encoded_len().(version)).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().()
335 }
336
337 #[cfg(test)]
338 mod optimize_testsrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/ {
339 use craterust-analyzer cargo qrcode 0.14.1 crate/::optimizerust-analyzer cargo qrcode 0.14.1 optimize/::{total_encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/total_encoded_len()., Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#};
340 use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::{Moderust-analyzer cargo qrcode 0.14.1 types/Mode#, Versionrust-analyzer cargo qrcode 0.14.1 types/Version#};
341
342 fn test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(given: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#>, expected: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment#>, version: Versionrust-analyzer cargo qrcode 0.14.1 types/Version#) {
343 let prev_len = total_encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/total_encoded_len().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().given, version);
344 let opt_segs = Optimizerrust-analyzer cargo qrcode 0.14.1 optimize/Optimizer#::newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Optimizer<I>`]new().(given.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|seg| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().seg), version).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
345 let new_len = total_encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/total_encoded_len().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().opt_segs, version);
346 if given rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]ne().!=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]ne(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]ne().opt_segs {
347 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(prev_len >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). new_len, "{} > {}", prev_len, new_len);
348 }
349 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
350 opt_segs == expected,
351 "Optimization gave something better: {} < {} ({:?})",
352 new_len,
353 total_encoded_lenrust-analyzer cargo qrcode 0.14.1 optimize/total_encoded_len().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().expected, version),
354 opt_segs
355 );
356 }
357
358 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
359 fn test_example_1rust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_example_1().() {
360 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
361 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
362 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 3 },
363 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 3, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 6 },
364 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 6, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 10 },
365 ],
366 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
367 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 6 },
368 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 6, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 10 },
369 ],
370 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1),
371 );
372 }
373
374 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
375 fn test_example_2rust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_example_2().() {
376 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
377 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
378 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 29 },
379 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 29, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 30 },
380 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 30, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 32 },
381 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 32, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 35 },
382 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 35, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 38 },
383 ],
384 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
385 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 29 },
386 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 29, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 38 },
387 ],
388 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(9),
389 );
390 }
391
392 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
393 fn test_example_3rust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_example_3().() {
394 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
395 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
396 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
397 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 4, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 5 },
398 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 5, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 6 },
399 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 6, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 8 },
400 ],
401 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 8 }],
402 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1),
403 );
404 }
405
406 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
407 fn test_example_4rust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_example_4().() {
408 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
409 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 10 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 10, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 11 }],
410 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Kanjirust-analyzer cargo qrcode 0.14.1 types/Mode#Kanji#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 10 }, Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Byterust-analyzer cargo qrcode 0.14.1 types/Mode#Byte#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 10, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 11 }],
411 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(1),
412 );
413 }
414
415 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
416 fn test_annex_j_guideline_1arust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_annex_j_guideline_1a().() {
417 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
418 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
419 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 3 },
420 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 3, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
421 ],
422 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
423 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 3 },
424 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 3, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
425 ],
426 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(2),
427 );
428 }
429
430 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
431 fn test_annex_j_guideline_1brust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_annex_j_guideline_1b().() {
432 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
433 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
434 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 2 },
435 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 2, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
436 ],
437 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 }],
438 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(2),
439 );
440 }
441
442 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
443 fn test_annex_j_guideline_1crust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_annex_j_guideline_1c().() {
444 test_optimization_resultrust-analyzer cargo qrcode 0.14.1 optimize/optimize_tests/test_optimization_result().(
445 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
446 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Numericrust-analyzer cargo qrcode 0.14.1 types/Mode#Numeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 3 },
447 Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 3, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 },
448 ],
449 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Segmentrust-analyzer cargo qrcode 0.14.1 optimize/Segment# { moderust-analyzer cargo qrcode 0.14.1 optimize/Segment#mode.: Moderust-analyzer cargo qrcode 0.14.1 types/Mode#::Alphanumericrust-analyzer cargo qrcode 0.14.1 types/Mode#Alphanumeric#, beginrust-analyzer cargo qrcode 0.14.1 optimize/Segment#begin.: 0, endrust-analyzer cargo qrcode 0.14.1 optimize/Segment#end.: 4 }],
450 Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Microrust-analyzer cargo qrcode 0.14.1 types/Version#Micro#(3),
451 );
452 }
453 }
454
455 #[cfg(feature = "bench")]
456 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
457 fn bench_optimizerust-analyzer cargo qrcode 0.14.1 optimize/bench_optimize().(bencher: &mut testrust-analyzer cargo test https://github.com/rust-lang/rust/library/test crate/::Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
458 use craterust-analyzer cargo qrcode 0.14.1 crate/::typesrust-analyzer cargo qrcode 0.14.1 types/::Versionrust-analyzer cargo qrcode 0.14.1 types/Version#;
459
460 let data = b"QR\x83R\x81[\x83h\x81i\x83L\x83\x85\x81[\x83A\x81[\x83\x8b\x83R\x81[\x83h\x81j\
461 \x82\xc6\x82\xcd\x81A1994\x94N\x82\xc9\x83f\x83\x93\x83\\\x81[\x82\xcc\x8aJ\
462 \x94\xad\x95\x94\x96\xe5\x81i\x8c\xbb\x8d\xdd\x82\xcd\x95\xaa\x97\xa3\x82\xb5\x83f\
463 \x83\x93\x83\\\x81[\x83E\x83F\x81[\x83u\x81j\x82\xaa\x8aJ\x94\xad\x82\xb5\x82\xbd\
464 \x83}\x83g\x83\x8a\x83b\x83N\x83X\x8c^\x93\xf1\x8e\x9f\x8c\xb3\x83R\x81[\x83h\
465 \x82\xc5\x82\xa0\x82\xe9\x81B\x82\xc8\x82\xa8\x81AQR\x83R\x81[\x83h\x82\xc6\
466 \x82\xa2\x82\xa4\x96\xbc\x8f\xcc\x81i\x82\xa8\x82\xe6\x82\xd1\x92P\x8c\xea\x81j\
467 \x82\xcd\x83f\x83\x93\x83\\\x81[\x83E\x83F\x81[\x83u\x82\xcc\x93o\x98^\x8f\xa4\
468 \x95W\x81i\x91\xe64075066\x8d\x86\x81j\x82\xc5\x82\xa0\x82\xe9\x81BQR\x82\xcd\
469 Quick Response\x82\xc9\x97R\x97\x88\x82\xb5\x81A\x8d\x82\x91\xac\x93\xc7\x82\xdd\
470 \x8e\xe6\x82\xe8\x82\xaa\x82\xc5\x82\xab\x82\xe9\x82\xe6\x82\xa4\x82\xc9\x8aJ\
471 \x94\xad\x82\xb3\x82\xea\x82\xbd\x81B\x93\x96\x8f\x89\x82\xcd\x8e\xa9\x93\xae\
472 \x8e\xd4\x95\x94\x95i\x8dH\x8f\xea\x82\xe2\x94z\x91\x97\x83Z\x83\x93\x83^\x81[\
473 \x82\xc8\x82\xc7\x82\xc5\x82\xcc\x8eg\x97p\x82\xf0\x94O\x93\xaa\x82\xc9\x8aJ\
474 \x94\xad\x82\xb3\x82\xea\x82\xbd\x82\xaa\x81A\x8c\xbb\x8d\xdd\x82\xc5\x82\xcd\x83X\
475 \x83}\x81[\x83g\x83t\x83H\x83\x93\x82\xcc\x95\x81\x8by\x82\xc8\x82\xc7\x82\xc9\
476 \x82\xe6\x82\xe8\x93\xfa\x96{\x82\xc9\x8c\xc0\x82\xe7\x82\xb8\x90\xa2\x8aE\x93I\
477 \x82\xc9\x95\x81\x8by\x82\xb5\x82\xc4\x82\xa2\x82\xe9\x81B";
478 bencher.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| Parserrust-analyzer cargo qrcode 0.14.1 optimize/Parser#::newrust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`]new().(data).optimizerust-analyzer cargo qrcode 0.14.1 optimize/impl#[`Parser<'a>`]optimize().(Versionrust-analyzer cargo qrcode 0.14.1 types/Version#::Normalrust-analyzer cargo qrcode 0.14.1 types/Version#Normal#(15)));
479 }
480
481 //}}}
482 //------------------------------------------------------------------------------
483 //{{{ Internal types and data for parsing
484
485 /// All values of `u8` can be split into 9 different character sets when
486 /// determining which encoding to use. This enum represents these groupings for
487 /// parsing purpose.
488 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
489 enum ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet# {
490 /// The end of string.
491 Endrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#End# = 0,
492
493 /// All symbols supported by the Alphanumeric encoding, i.e. space, `$`, `%`,
494 /// `*`, `+`, `-`, `.`, `/` and `:`.
495 Symbolrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Symbol# = 1,
496
497 /// All numbers (0–9).
498 Numericrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Numeric# = 2,
499
500 /// All uppercase letters (A–Z). These characters may also appear in the
501 /// second byte of a Shift JIS 2-byte encoding.
502 Alpharust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Alpha# = 3,
503
504 /// The first byte of a Shift JIS 2-byte encoding, in the range 0x81–0x9f.
505 KanjiHi1rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi1# = 4,
506
507 /// The first byte of a Shift JIS 2-byte encoding, in the range 0xe0–0xea.
508 KanjiHi2rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi2# = 5,
509
510 /// The first byte of a Shift JIS 2-byte encoding, of value 0xeb. This is
511 /// different from the other two range that the second byte has a smaller
512 /// range.
513 KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi3# = 6,
514
515 /// The second byte of a Shift JIS 2-byte encoding, in the range 0x40–0xbf,
516 /// excluding letters (covered by `Alpha`), 0x81–0x9f (covered by `KanjiHi1`),
517 /// and the invalid byte 0x7f.
518 KanjiLo1rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiLo1# = 7,
519
520 /// The second byte of a Shift JIS 2-byte encoding, in the range 0xc0–0xfc,
521 /// excluding the range 0xe0–0xeb (covered by `KanjiHi2` and `KanjiHi3`).
522 /// This half of byte-pair cannot appear as the second byte leaded by
523 /// `KanjiHi3`.
524 KanjiLo2rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiLo2# = 8,
525
526 /// Any other values not covered by the above character sets.
527 Byterust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Byte# = 9,
528 }
529
530 impl ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet# {
531 /// Determines which character set a byte is in.
532 fn from_u8rust-analyzer cargo qrcode 0.14.1 optimize/impl#[ExclCharSet]from_u8().(c: u8) -> Selfrust-analyzer cargo qrcode 0.14.1 optimize/impl#[ExclCharSet] {
533 match c {
534 0x20 | 0x24 | 0x25 | 0x2a | 0x2b | 0x2d..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x2f | 0x3a => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::Symbolrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Symbol#,
535 0x30..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x39 => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Numeric#,
536 0x41..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x5a => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Alpha#,
537 0x81..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x9f => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::KanjiHi1rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi1#,
538 0xe0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0xea => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::KanjiHi2rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi2#,
539 0xeb => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiHi3#,
540 0x40 | 0x5b..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0x7e | 0x80 | 0xa0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0xbf => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::KanjiLo1rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiLo1#,
541 0xc0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0xdf | 0xec..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0xfc => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::KanjiLo2rust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#KanjiLo2#,
542 _ => ExclCharSetrust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#::Byterust-analyzer cargo qrcode 0.14.1 optimize/ExclCharSet#Byte#,
543 }
544 }
545 }
546
547 /// The current parsing state.
548 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
549 enum Staterust-analyzer cargo qrcode 0.14.1 optimize/State# {
550 /// Just initialized.
551 Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init# = 0,
552
553 /// Inside a string that can be exclusively encoded as Numeric.
554 Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric# = 10,
555
556 /// Inside a string that can be exclusively encoded as Alphanumeric.
557 Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha# = 20,
558
559 /// Inside a string that can be exclusively encoded as 8-Bit Byte.
560 Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte# = 30,
561
562 /// Just encountered the first byte of a Shift JIS 2-byte sequence of the
563 /// set `KanjiHi1` or `KanjiHi2`.
564 KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12# = 40,
565
566 /// Just encountered the first byte of a Shift JIS 2-byte sequence of the
567 /// set `KanjiHi3`.
568 KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3# = 50,
569
570 /// Inside a string that can be exclusively encoded as Kanji.
571 Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji# = 60,
572 }
573
574 /// What should the parser do after a state transition.
575 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
576 enum Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action# {
577 /// The parser should do nothing.
578 Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#,
579
580 /// Push the current segment as a Numeric string, and reset the marks.
581 Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#,
582
583 /// Push the current segment as an Alphanumeric string, and reset the marks.
584 Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#,
585
586 /// Push the current segment as a 8-Bit Byte string, and reset the marks.
587 Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#,
588
589 /// Push the current segment as a Kanji string, and reset the marks.
590 Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#,
591
592 /// Push the current segment excluding the last byte as a Kanji string, then
593 /// push the remaining single byte as a Byte string, and reset the marks.
594 KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#,
595 }
596
597 static STATE_TRANSITIONrust-analyzer cargo qrcode 0.14.1 optimize/STATE_TRANSITION.: [(Staterust-analyzer cargo qrcode 0.14.1 optimize/State#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#); 70] = [
598 // STATE_TRANSITION[current_state + next_character] == (next_state, what_to_do)
599
600 // Init state:
601 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // End
602 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Symbol
603 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Numeric
604 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Alpha
605 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi1
606 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi2
607 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi3
608 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo1
609 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo2
610 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Byte
611 // Numeric state:
612 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // End
613 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // Symbol
614 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Numeric
615 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // Alpha
616 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // KanjiHi1
617 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // KanjiHi2
618 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // KanjiHi3
619 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // KanjiLo1
620 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // KanjiLo2
621 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/Action#Numeric#), // Byte
622 // Alpha state:
623 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // End
624 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Symbol
625 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // Numeric
626 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Alpha
627 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // KanjiHi1
628 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // KanjiHi2
629 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // KanjiHi3
630 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // KanjiLo1
631 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // KanjiLo2
632 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/Action#Alpha#), // Byte
633 // Byte state:
634 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // End
635 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // Symbol
636 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // Numeric
637 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // Alpha
638 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // KanjiHi1
639 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // KanjiHi2
640 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Byterust-analyzer cargo qrcode 0.14.1 optimize/Action#Byte#), // KanjiHi3
641 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo1
642 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo2
643 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Byte
644 // KanjiHi12 state:
645 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // End
646 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Symbol
647 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Numeric
648 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Alpha
649 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi1
650 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi2
651 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi3
652 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo1
653 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo2
654 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Byte
655 // KanjiHi3 state:
656 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // End
657 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Symbol
658 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Numeric
659 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // Alpha
660 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi1
661 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // KanjiHi2
662 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // KanjiHi3
663 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/State#Kanji#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiLo1
664 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // KanjiLo2
665 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::KanjiAndSingleByterust-analyzer cargo qrcode 0.14.1 optimize/Action#KanjiAndSingleByte#), // Byte
666 // Kanji state:
667 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Initrust-analyzer cargo qrcode 0.14.1 optimize/State#Init#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // End
668 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // Symbol
669 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Numericrust-analyzer cargo qrcode 0.14.1 optimize/State#Numeric#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // Numeric
670 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Alpharust-analyzer cargo qrcode 0.14.1 optimize/State#Alpha#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // Alpha
671 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi1
672 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi12rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi12#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi2
673 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::KanjiHi3rust-analyzer cargo qrcode 0.14.1 optimize/State#KanjiHi3#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Idlerust-analyzer cargo qrcode 0.14.1 optimize/Action#Idle#), // KanjiHi3
674 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // KanjiLo1
675 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // KanjiLo2
676 (Staterust-analyzer cargo qrcode 0.14.1 optimize/State#::Byterust-analyzer cargo qrcode 0.14.1 optimize/State#Byte#, Actionrust-analyzer cargo qrcode 0.14.1 optimize/Action#::Kanjirust-analyzer cargo qrcode 0.14.1 optimize/Action#Kanji#), // Byte
677 ];
678
679 //}}}