@@ -6,7 +6,7 @@ use crate::num::NonZero;
66use crate :: ops:: Range ;
77use crate :: { ascii, fmt} ;
88
9- const HEX_DIGITS : [ ascii:: Char ; 16 ] = * b"0123456789abcdef" . as_ascii ( ) . unwrap ( ) ;
9+ const HEX_DIGITS : [ ascii:: Char ; 16 ] = * b"0123456789abcdef" . as_escape_seq ( ) . unwrap ( ) ;
1010
1111#[ inline]
1212const fn backslash < const N : usize > ( a : ascii:: Char ) -> ( [ ascii:: Char ; N ] , Range < u8 > ) {
@@ -217,12 +217,12 @@ impl<const N: usize, ESCAPING> EscapeIterInner<N, ESCAPING> {
217217
218218 /// # Safety
219219 ///
220- /// The caller must ensure that `self` contains an escape sequence.
220+ /// `self` must contain an escape sequence.
221221 #[ inline]
222- unsafe fn as_ascii ( & self ) -> & [ ascii:: Char ] {
223- // SAFETY: `self.data.escape_seq` contains an escape sequence, as is guaranteed
224- // by the caller, and `self.alive` is guaranteed to be a valid range for
225- // indexing `self.data` .
222+ unsafe fn as_escape_seq ( & self ) -> & [ ascii:: Char ] {
223+ // SAFETY: `self.data.escape_seq` contains an escape sequence, as is
224+ // guaranteed by the caller, and in that case `self.alive` is guaranteed
225+ // to be a valid range for indexing it .
226226 unsafe {
227227 self . data
228228 . escape_seq
@@ -232,9 +232,9 @@ impl<const N: usize, ESCAPING> EscapeIterInner<N, ESCAPING> {
232232
233233 /// # Safety
234234 ///
235- /// The caller must ensure that `self` contains a literal `char`.
235+ /// `self` must contain a literal `char`.
236236 #[ inline]
237- unsafe fn as_char ( & self ) -> char {
237+ unsafe fn as_literal ( & self ) -> char {
238238 // SAFETY: `self.data.literal` contains a literal `char`,
239239 // as is guaranteed by the caller.
240240 unsafe { self . data . literal }
@@ -295,7 +295,7 @@ impl<const N: usize> EscapeIterInner<N, MaybeEscaped> {
295295
296296 if self . is_literal ( ) {
297297 // SAFETY: We just checked that `self` contains a literal `char`.
298- return Some ( unsafe { self . as_char ( ) } ) ;
298+ return Some ( unsafe { self . as_literal ( ) } ) ;
299299 }
300300
301301 // SAFETY: We just checked that `self` contains an escape sequence, and
@@ -307,18 +307,18 @@ impl<const N: usize> EscapeIterInner<N, MaybeEscaped> {
307307impl < const N : usize > fmt:: Display for EscapeIterInner < N , AlwaysEscaped > {
308308 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
309309 // SAFETY: The `AlwaysEscaped` marker guarantees that `self` contains an escape sequence.
310- f. write_str ( unsafe { self . as_ascii ( ) . as_str ( ) } )
310+ f. write_str ( unsafe { self . as_escape_seq ( ) . as_str ( ) } )
311311 }
312312}
313313
314314impl < const N : usize > fmt:: Display for EscapeIterInner < N , MaybeEscaped > {
315315 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
316316 if self . is_literal ( ) {
317317 // SAFETY: We just checked that `self` contains a literal `char`.
318- f. write_char ( unsafe { self . as_char ( ) } )
318+ f. write_char ( unsafe { self . as_literal ( ) } )
319319 } else {
320320 // SAFETY: We just checked that `self` contains an escape sequence.
321- f. write_str ( unsafe { self . as_ascii ( ) . as_str ( ) } )
321+ f. write_str ( unsafe { self . as_escape_seq ( ) . as_str ( ) } )
322322 }
323323 }
324324}
@@ -327,7 +327,7 @@ impl<const N: usize> fmt::Debug for EscapeIterInner<N, AlwaysEscaped> {
327327 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
328328 f. debug_tuple ( "EscapeIterInner" )
329329 // SAFETY: The `AlwaysEscaped` marker guarantees that `self` contains an escape sequence.
330- . field ( unsafe { & self . as_ascii ( ) } )
330+ . field ( unsafe { & self . as_escape_seq ( ) } )
331331 . finish ( )
332332 }
333333}
@@ -337,10 +337,10 @@ impl<const N: usize> fmt::Debug for EscapeIterInner<N, MaybeEscaped> {
337337 let mut d = f. debug_tuple ( "EscapeIterInner" ) ;
338338 if self . is_literal ( ) {
339339 // SAFETY: We just checked that `self` contains a literal `char`.
340- d. field ( unsafe { & self . as_char ( ) } ) ;
340+ d. field ( unsafe { & self . as_literal ( ) } ) ;
341341 } else {
342342 // SAFETY: We just checked that `self` contains an escape sequence.
343- d. field ( unsafe { & self . as_ascii ( ) } ) ;
343+ d. field ( unsafe { & self . as_escape_seq ( ) } ) ;
344344 }
345345 d. finish ( )
346346 }
0 commit comments