File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ use crate::Error;
16
16
17
17
const CHECKSUM_CHARSET : & [ u8 ] = b"qpzry9x8gf2tvdw0s3jn54khce6mua7l" ;
18
18
19
+ const CHECKSUM_LENGTH : usize = 8 ;
20
+
19
21
fn poly_mod ( mut c : u64 , val : u64 ) -> u64 {
20
22
let c0 = c >> 35 ;
21
23
@@ -117,15 +119,15 @@ impl Engine {
117
119
118
120
/// Obtains the checksum characters of all the data thus-far fed to the
119
121
/// engine without allocating, to get a string use [`Self::checksum`].
120
- pub fn checksum_chars ( & mut self ) -> [ char ; 8 ] {
122
+ pub fn checksum_chars ( & mut self ) -> [ char ; CHECKSUM_LENGTH ] {
121
123
if self . clscount > 0 {
122
124
self . c = poly_mod ( self . c , self . cls ) ;
123
125
}
124
- ( 0 ..8 ) . for_each ( |_| self . c = poly_mod ( self . c , 0 ) ) ;
126
+ ( 0 ..CHECKSUM_LENGTH ) . for_each ( |_| self . c = poly_mod ( self . c , 0 ) ) ;
125
127
self . c ^= 1 ;
126
128
127
- let mut chars = [ 0 as char ; 8 ] ;
128
- for j in 0 ..8 {
129
+ let mut chars = [ 0 as char ; CHECKSUM_LENGTH ] ;
130
+ for j in 0 ..CHECKSUM_LENGTH {
129
131
chars[ j] = CHECKSUM_CHARSET [ ( ( self . c >> ( 5 * ( 7 - j) ) ) & 31 ) as usize ] as char ;
130
132
}
131
133
chars
You can’t perform that action at this time.
0 commit comments