1- use std:: collections:: HashMap ;
1+ use std:: collections:: { HashMap , HashSet } ;
22use std:: iter:: Iterator ;
33
44fn main ( ) {
@@ -70,6 +70,7 @@ fn main() {
7070}
7171
7272fn print_encode_table ( alphabet : & [ u8 ] , const_name : & str , indent_depth : usize ) {
73+ check_alphabet ( alphabet) ;
7374 println ! ( "#[rustfmt::skip]" ) ;
7475 println ! (
7576 "{:width$}pub const {}: &[u8; 64] = &[" ,
@@ -95,6 +96,7 @@ fn print_encode_table(alphabet: &[u8], const_name: &str, indent_depth: usize) {
9596}
9697
9798fn print_decode_table ( alphabet : & [ u8 ] , const_name : & str , indent_depth : usize ) {
99+ check_alphabet ( alphabet) ;
98100 // map of alphabet bytes to 6-bit morsels
99101 let mut input_to_morsel = HashMap :: < u8 , u8 > :: new ( ) ;
100102
@@ -140,3 +142,10 @@ fn print_decode_table(alphabet: &[u8], const_name: &str, indent_depth: usize) {
140142 }
141143 println ! ( "{:width$}];" , "" , width = indent_depth) ;
142144}
145+
146+ fn check_alphabet ( alphabet : & [ u8 ] ) {
147+ assert_eq ! ( 64 , alphabet. len( ) ) ;
148+ let mut set: HashSet < u8 > = HashSet :: new ( ) ;
149+ set. extend ( alphabet) ;
150+ assert_eq ! ( 64 , set. len( ) ) ;
151+ }
0 commit comments