Skip to content

Commit 2fd14ca

Browse files
authored
Fix comments.
1 parent 269ce89 commit 2fd14ca

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

library/core/src/escape.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::num::NonZero;
66
use crate::ops::Range;
77
use 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]
1212
const 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> {
307307
impl<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

314314
impl<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

Comments
 (0)