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;
1616
1717const CHECKSUM_CHARSET : & [ u8 ] = b"qpzry9x8gf2tvdw0s3jn54khce6mua7l" ;
1818
19+ const CHECKSUM_LENGTH : usize = 8 ;
20+
1921fn poly_mod ( mut c : u64 , val : u64 ) -> u64 {
2022 let c0 = c >> 35 ;
2123
@@ -117,15 +119,15 @@ impl Engine {
117119
118120 /// Obtains the checksum characters of all the data thus-far fed to the
119121 /// 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 ] {
121123 if self . clscount > 0 {
122124 self . c = poly_mod ( self . c , self . cls ) ;
123125 }
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 ) ) ;
125127 self . c ^= 1 ;
126128
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 {
129131 chars[ j] = CHECKSUM_CHARSET [ ( ( self . c >> ( 5 * ( 7 - j) ) ) & 31 ) as usize ] as char ;
130132 }
131133 chars
You can’t perform that action at this time.
0 commit comments