| 1 | //! Places data on a matrix |
| 2 | #![deny(unsafe_code)] |
| 3 | #![warn(missing_docs)] |
| 4 | |
| 5 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::compactrust-analyzer cargo fast_qr 0.13.1 compact/::CompactQRrust-analyzer cargo fast_qr 0.13.1 compact/CompactQR#; |
| 6 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::datamaskingrust-analyzer cargo fast_qr 0.13.1 datamasking/::Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#; |
| 7 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::encoderust-analyzer cargo fast_qr 0.13.1 encode/::Moderust-analyzer cargo fast_qr 0.13.1 encode/Mode#; |
| 8 | |
| 9 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::modulerust-analyzer cargo fast_qr 0.13.1 module/::ModuleTyperust-analyzer cargo fast_qr 0.13.1 module/ModuleType#; |
| 10 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::{datamaskingrust-analyzer cargo fast_qr 0.13.1 datamasking/, defaultrust-analyzer cargo fast_qr 0.13.1 default/, encoderust-analyzer cargo fast_qr 0.13.1 encode/, polynomialsrust-analyzer cargo fast_qr 0.13.1 polynomials/, scorerust-analyzer cargo fast_qr 0.13.1 score/, QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode#}; |
| 11 | use craterust-analyzer cargo fast_qr 0.13.1 crate/::{Versionrust-analyzer cargo fast_qr 0.13.1 version/Version#, ECLrust-analyzer cargo fast_qr 0.13.1 ecl/ECL#}; |
| 12 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/Rev#; |
| 13 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#; |
| 14 | |
| 15 | pub enum BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange# { |
| 16 | Forwardrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Forward#(Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>), |
| 17 | Backwardsrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Backwards#(Revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/Rev#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>>), |
| 18 | } |
| 19 | |
| 20 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange# { |
| 21 | type Itemrust-analyzer cargo fast_qr 0.13.1 placement/impl#[BiRange][Iterator]Item# = usize; |
| 22 | fn nextrust-analyzer cargo fast_qr 0.13.1 placement/impl#[BiRange][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize> { |
| 23 | match self { |
| 24 | BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange#::Forwardrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Forward#(range) => range.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/range/impl#[`ops::Range<A>`][Iterator]next().(), |
| 25 | BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange#::Backwardsrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Backwards#(range) => range.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/impl#[`Rev<I>`][Iterator]next().(), |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | #[cfg(test)] |
| 31 | pub fn test_place_on_matrix_datarust-analyzer cargo fast_qr 0.13.1 placement/test_place_on_matrix_data().(qr: &mut QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode#, structure_as_binarystring: &CompactQRrust-analyzer cargo fast_qr 0.13.1 compact/CompactQR#) { |
| 32 | place_on_matrix_datarust-analyzer cargo fast_qr 0.13.1 placement/place_on_matrix_data().(qr, structure_as_binarystring); |
| 33 | } |
| 34 | |
| 35 | /// Places the data on the matrix |
| 36 | pub fn place_on_matrix_datarust-analyzer cargo fast_qr 0.13.1 placement/place_on_matrix_data().(qr: &mut QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode#, structure_as_binarystring: &CompactQRrust-analyzer cargo fast_qr 0.13.1 compact/CompactQR#) { |
| 37 | let structure_bytes_tmp = structure_as_binarystring.get_datarust-analyzer cargo fast_qr 0.13.1 compact/impl#[CompactQR]get_data().(); |
| 38 | |
| 39 | let mut rev = true; |
| 40 | let mut idx = 0; |
| 41 | |
| 42 | // 0, 2, 4, 7, 9, .., N (skipping 6) |
| 43 | for x in (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6).chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(7..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#qr.sizerust-analyzer cargo fast_qr 0.13.1 qr/QRCode#size.).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().step_byrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#step_by().(2) { |
| 44 | let y_range = if rev { |
| 45 | BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange#::Backwardsrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Backwards#((0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#qr.sizerust-analyzer cargo fast_qr 0.13.1 qr/QRCode#size.).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()) |
| 46 | } else { |
| 47 | BiRangerust-analyzer cargo fast_qr 0.13.1 placement/BiRange#::Forwardrust-analyzer cargo fast_qr 0.13.1 placement/BiRange#Forward#(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#qr.sizerust-analyzer cargo fast_qr 0.13.1 qr/QRCode#size.) |
| 48 | }; |
| 49 | |
| 50 | for y in y_range { |
| 51 | if qr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().y]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index().x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index()..module_typerust-analyzer cargo fast_qr 0.13.1 module/impl#[Module]module_type().() rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq().==rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq(). rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq().ModuleTyperust-analyzer cargo fast_qr 0.13.1 module/ModuleType#::Datarust-analyzer cargo fast_qr 0.13.1 module/ModuleType#Data# { |
| 52 | let c = structure_bytes_tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx 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().8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().(7 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().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().8)); |
| 53 | idx 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; |
| 54 | qr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().y]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut().x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut()..setrust-analyzer cargo fast_qr 0.13.1 module/impl#[Module]set().(c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0); |
| 55 | } |
| 56 | if qr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().y]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index().x 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]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index()..module_typerust-analyzer cargo fast_qr 0.13.1 module/impl#[Module]module_type().() rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq().==rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq(). rust-analyzer cargo fast_qr 0.13.1 module/impl#[ModuleType][`PartialEq<Self>`]eq().ModuleTyperust-analyzer cargo fast_qr 0.13.1 module/ModuleType#::Datarust-analyzer cargo fast_qr 0.13.1 module/ModuleType#Data# { |
| 57 | let c = structure_bytes_tmp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx 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().8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().(7 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().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().8)); |
| 58 | idx 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; |
| 59 | qr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().y]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut().x 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]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut()..setrust-analyzer cargo fast_qr 0.13.1 module/impl#[Module]set().(c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | rev = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rev; |
| 64 | } |
| 65 | |
| 66 | #[cfg(debug_assertions)] |
| 67 | { |
| 68 | let version = Versionrust-analyzer cargo fast_qr 0.13.1 version/Version#::from_nrust-analyzer cargo fast_qr 0.13.1 version/impl#[Version]from_n().(qr.sizerust-analyzer cargo fast_qr 0.13.1 qr/QRCode#size.); |
| 69 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(idx -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). version.missing_bitsrust-analyzer cargo fast_qr 0.13.1 version/impl#[Version]missing_bits().(), version.max_bytesrust-analyzer cargo fast_qr 0.13.1 version/impl#[Version]max_bytes().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 8); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | const MASKSrust-analyzer cargo fast_qr 0.13.1 placement/MASKS.: [Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#; 8] = [ |
| 74 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::Checkerboardrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#Checkerboard#, |
| 75 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::HorizontalLinesrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#HorizontalLines#, |
| 76 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::VerticalLinesrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#VerticalLines#, |
| 77 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::DiagonalLinesrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#DiagonalLines#, |
| 78 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::LargeCheckerboardrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#LargeCheckerboard#, |
| 79 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::Fieldsrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#Fields#, |
| 80 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::Diamondsrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#Diamonds#, |
| 81 | Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#::Meadowrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#Meadow#, |
| 82 | ]; |
| 83 | |
| 84 | /// Main function to place everything in the `QRCode`, returns a valid matrix |
| 85 | pub fn place_on_matrixrust-analyzer cargo fast_qr 0.13.1 placement/place_on_matrix().( |
| 86 | structure_as_binarystring: &CompactQRrust-analyzer cargo fast_qr 0.13.1 compact/CompactQR#, |
| 87 | quality: ECLrust-analyzer cargo fast_qr 0.13.1 ecl/ECL#, |
| 88 | version: Versionrust-analyzer cargo fast_qr 0.13.1 version/Version#, |
| 89 | mask: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#>, |
| 90 | ) -> QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode# { |
| 91 | let mut best_score = u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.; |
| 92 | let mut best_mask = MASKSrust-analyzer cargo fast_qr 0.13.1 placement/MASKS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 93 | |
| 94 | let mut qr = defaultrust-analyzer cargo fast_qr 0.13.1 default/::create_matrixrust-analyzer cargo fast_qr 0.13.1 default/create_matrix().(version); |
| 95 | place_on_matrix_datarust-analyzer cargo fast_qr 0.13.1 placement/place_on_matrix_data().(&mut qr, structure_as_binarystring); |
| 96 | |
| 97 | let transpose = defaultrust-analyzer cargo fast_qr 0.13.1 default/::transposerust-analyzer cargo fast_qr 0.13.1 default/transpose().(&qr); |
| 98 | |
| 99 | for mask in MASKSrust-analyzer cargo fast_qr 0.13.1 placement/MASKS. { |
| 100 | let mut copy = qr.clonerust-analyzer cargo fast_qr 0.13.1 qr/impl#[QRCode][Clone]clone().(); |
| 101 | let copy_transpose = transpose.clonerust-analyzer cargo fast_qr 0.13.1 qr/impl#[QRCode][Clone]clone().(); |
| 102 | |
| 103 | datamaskingrust-analyzer cargo fast_qr 0.13.1 datamasking/::maskrust-analyzer cargo fast_qr 0.13.1 datamasking/mask().(&mut copy, mask); |
| 104 | let matrix_score = scorerust-analyzer cargo fast_qr 0.13.1 score/::scorerust-analyzer cargo fast_qr 0.13.1 score/score().(©, ©_transpose); |
| 105 | if matrix_score rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]lt().best_score { |
| 106 | best_score = matrix_score; |
| 107 | best_mask = mask; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | best_mask = mask.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(best_mask); |
| 112 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().mask = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(best_mask); |
| 113 | |
| 114 | defaultrust-analyzer cargo fast_qr 0.13.1 default/::create_matrix_format_inforust-analyzer cargo fast_qr 0.13.1 default/create_matrix_format_info().(&mut qr, quality, best_mask); |
| 115 | datamaskingrust-analyzer cargo fast_qr 0.13.1 datamasking/::maskrust-analyzer cargo fast_qr 0.13.1 datamasking/mask().(&mut qr, best_mask); |
| 116 | |
| 117 | qr.maskrust-analyzer cargo fast_qr 0.13.1 qr/QRCode#mask. = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().mask; |
| 118 | qr |
| 119 | } |
| 120 | |
| 121 | /// Generate the whole matrix |
| 122 | pub fn create_matrixrust-analyzer cargo fast_qr 0.13.1 placement/create_matrix().( |
| 123 | input: &[u8], |
| 124 | ecl: ECLrust-analyzer cargo fast_qr 0.13.1 ecl/ECL#, |
| 125 | mode: Moderust-analyzer cargo fast_qr 0.13.1 encode/Mode#, |
| 126 | version: Versionrust-analyzer cargo fast_qr 0.13.1 version/Version#, |
| 127 | mask: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Maskrust-analyzer cargo fast_qr 0.13.1 datamasking/Mask#>, |
| 128 | ) -> QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode# { |
| 129 | let data_codewords = encoderust-analyzer cargo fast_qr 0.13.1 encode/::encoderust-analyzer cargo fast_qr 0.13.1 encode/encode().(input, ecl, mode, version); |
| 130 | let structure = polynomialsrust-analyzer cargo fast_qr 0.13.1 polynomials/::structurerust-analyzer cargo fast_qr 0.13.1 polynomials/structure().(data_codewords.get_datarust-analyzer cargo fast_qr 0.13.1 compact/impl#[CompactQR]get_data().(), ecl, version); |
| 131 | |
| 132 | let max = version.max_bytesrust-analyzer cargo fast_qr 0.13.1 version/impl#[Version]max_bytes().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8; |
| 133 | let structure_binstring = CompactQRrust-analyzer cargo fast_qr 0.13.1 compact/CompactQR#::from_arrayrust-analyzer cargo fast_qr 0.13.1 compact/impl#[CompactQR]from_array().(&structure, max 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().version.missing_bitsrust-analyzer cargo fast_qr 0.13.1 version/impl#[Version]missing_bits().()); |
| 134 | |
| 135 | QRCoderust-analyzer cargo fast_qr 0.13.1 qr/QRCode# { |
| 136 | moderust-analyzer cargo fast_qr 0.13.1 qr/QRCode#mode.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mode), |
| 137 | eclrust-analyzer cargo fast_qr 0.13.1 qr/QRCode#ecl.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ecl), |
| 138 | versionrust-analyzer cargo fast_qr 0.13.1 qr/QRCode#version.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(version), |
| 139 | ..place_on_matrixrust-analyzer cargo fast_qr 0.13.1 placement/place_on_matrix().(&structure_binstring, ecl, version, mask) |
| 140 | } |
| 141 | } |