@@ -68,7 +68,7 @@ pub fn generate_enum_table(code_dir : &std::path::Path, name : &str, enum_values
6868 write ! ( fd, "///\n " ) ?;
6969 write ! ( fd, "/// # Returns\n " ) ?;
7070 write ! ( fd, "/// A {} attribute of the Unicode code-point.\n " , camel_name) ?;
71- write ! ( fd, "pub const fn get_{}(code_point: char) -> {}\n " , name, camel_name) ?;
71+ write ! ( fd, "#[must_use] pub const fn get_{}(code_point: char) -> {}\n " , name, camel_name) ?;
7272 write ! ( fd, "{{\n " ) ?;
7373 write ! ( fd, " const INDEX_MASK : usize = (1 << {}_INDEX_BITS) - 1;\n " , upper_name) ?;
7474 write ! ( fd, " const COLUMN_MASK : usize = (1 << {}_COLUMN_BITS) - 1;\n \n " , upper_name) ?;
@@ -85,7 +85,7 @@ pub fn generate_enum_table(code_dir : &std::path::Path, name : &str, enum_values
8585 write ! ( fd, " let index_bit_offset = index_offset % 8;\n " ) ?;
8686 write ! ( fd, " let mut index: usize = 0;\n " ) ?;
8787 let index_bytes_to_read = ( index_bits + 7 ) / 8 + 1 ;
88- for i in 0 ..index_bytes_to_read {
88+ for i in ( 0 ..index_bytes_to_read) . rev ( ) {
8989 write ! ( fd, " index |= ({}_INDEX[index_byte_offset + {}] as usize) << {};\n " , upper_name, i, i * 8 ) ?;
9090 }
9191 write ! ( fd, " index >>= index_bit_offset;\n " ) ?;
@@ -94,11 +94,10 @@ pub fn generate_enum_table(code_dir : &std::path::Path, name : &str, enum_values
9494 write ! ( fd, " let column_offset = (index * {}_CHUNK_SIZE + code_point_lo) * {}_COLUMN_BITS;\n " , upper_name, upper_name) ?;
9595 write ! ( fd, " let column_byte_offset = column_offset / 8;\n " ) ?;
9696 write ! ( fd, " let column_bit_offset = column_offset % 8;\n \n " ) ?;
97- write ! ( fd, " // Explicitly assert to replace a double bound check with single bound check.\n " ) ?;
98- write ! ( fd, " assert!(column_byte_offset + 1 < {}_COLUMN.len());\n " , upper_name) ?;
97+
9998 write ! ( fd, " let mut value: usize = 0;\n " ) ?;
10099 let column_bytes_to_read = ( column_bits + 7 ) / 8 + 1 ;
101- for i in 0 ..column_bytes_to_read {
100+ for i in ( 0 ..column_bytes_to_read) . rev ( ) {
102101 write ! ( fd, " value |= ({}_COLUMN[column_byte_offset + {}] as usize) << {};\n " , upper_name, i, i * 8 ) ?;
103102 }
104103 write ! ( fd, " value >>= column_bit_offset;\n " ) ?;
0 commit comments