@@ -7,7 +7,7 @@ const HEX_DIGITS: [u8; 16] = *b"0123456789abcdef";
77
88/// Escapes a byte into provided buffer; returns length of escaped
99/// representation.
10- pub ( super ) fn escape_ascii_into ( output : & mut [ u8 ; 4 ] , byte : u8 ) -> Range < u8 > {
10+ pub ( crate ) fn escape_ascii_into ( output : & mut [ u8 ; 4 ] , byte : u8 ) -> Range < u8 > {
1111 let ( data, len) = match byte {
1212 b'\t' => ( [ b'\\' , b't' , 0 , 0 ] , 2 ) ,
1313 b'\r' => ( [ b'\\' , b'r' , 0 , 0 ] , 2 ) ,
@@ -25,11 +25,10 @@ pub(super) fn escape_ascii_into(output: &mut [u8; 4], byte: u8) -> Range<u8> {
2525}
2626
2727/// Escapes a character into provided buffer using `\u{NNNN}` representation.
28- pub ( super ) fn escape_unicode_into ( output : & mut [ u8 ; 10 ] , ch : char ) -> Range < u8 > {
29- let ch = ( ch as u32 ) & 0x1f_ffff ;
30-
28+ pub ( crate ) fn escape_unicode_into ( output : & mut [ u8 ; 10 ] , ch : char ) -> Range < u8 > {
3129 output[ 9 ] = b'}' ;
3230
31+ let ch = ch as u32 ;
3332 output[ 3 ] = HEX_DIGITS [ ( ( ch >> 20 ) & 15 ) as usize ] ;
3433 output[ 4 ] = HEX_DIGITS [ ( ( ch >> 16 ) & 15 ) as usize ] ;
3534 output[ 5 ] = HEX_DIGITS [ ( ( ch >> 12 ) & 15 ) as usize ] ;
@@ -50,24 +49,25 @@ pub(super) fn escape_unicode_into(output: &mut [u8; 10], ch: char) -> Range<u8>
5049/// This is essentially equivalent to array’s IntoIter except that indexes are
5150/// limited to u8 to reduce size of the structure.
5251#[ derive( Clone , Debug ) ]
53- pub ( super ) struct EscapeIterInner < const N : usize > {
52+ pub ( crate ) struct EscapeIterInner < const N : usize > {
5453 // Invariant: data[alive] is all ASCII.
55- pub ( super ) data : [ u8 ; N ] ,
54+ pub ( crate ) data : [ u8 ; N ] ,
5655
5756 // Invariant: alive.start <= alive.end <= N.
58- pub ( super ) alive : Range < u8 > ,
57+ pub ( crate ) alive : Range < u8 > ,
5958}
6059
6160impl < const N : usize > EscapeIterInner < N > {
6261 pub fn new ( data : [ u8 ; N ] , alive : Range < u8 > ) -> Self {
62+ const { assert ! ( N < 256 ) } ;
6363 debug_assert ! ( alive. start <= alive. end && usize :: from( alive. end) <= N , "{alive:?}" ) ;
6464 let this = Self { data, alive } ;
6565 debug_assert ! ( this. as_bytes( ) . is_ascii( ) , "Expected ASCII, got {:?}" , this. as_bytes( ) ) ;
6666 this
6767 }
6868
6969 fn as_bytes ( & self ) -> & [ u8 ] {
70- & self . data [ ( self . alive . start as usize ) ..( self . alive . end as usize ) ]
70+ & self . data [ usize :: from ( self . alive . start ) ..usize :: from ( self . alive . end ) ]
7171 }
7272
7373 pub fn as_str ( & self ) -> & str {
0 commit comments