Skip to content

Commit 99986c7

Browse files
authored
Apply suggestions from code review
1 parent 5d817e9 commit 99986c7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

library/core/src/escape.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>
154154
#[derive(Clone, Copy)]
155155
union MaybeEscapedCharacter<const N: usize> {
156156
pub escaped: [ascii::Char; N],
157-
pub unescaped: char,
157+
pub literal: char,
158158
}
159159

160160
/// Marker type to indicate that the character is always escaped,
@@ -235,9 +235,9 @@ impl<const N: usize, ESCAPING> EscapeIterInner<N, ESCAPING> {
235235
/// The caller must ensure that `self` contains a literal `char`.
236236
#[inline]
237237
unsafe fn as_char(&self) -> char {
238-
// SAFETY: `self.data.unescaped` contains a literal `char`,
238+
// SAFETY: `self.data.literal` contains a literal `char`,
239239
// as is guaranteed by the caller.
240-
unsafe { self.data.unescaped }
240+
unsafe { self.data.literal }
241241
}
242242

243243
#[inline]
@@ -273,27 +273,27 @@ impl<const N: usize> EscapeIterInner<N, AlwaysEscaped> {
273273
}
274274

275275
impl<const N: usize> EscapeIterInner<N, MaybeEscaped> {
276-
const CHAR_FLAG: u8 = 0b10000000;
276+
const CHAR_FLAG: u8 = 0b1000_0000;
277277

278278
// This is the only way to create an `EscapeIterInner` with a literal `char`, which
279279
// means the `AlwaysEscaped` marker guarantees that `self` contains an escape sequence.
280280
pub(crate) const fn printable(c: char) -> Self {
281281
Self::new(
282-
MaybeEscapedCharacter { unescaped: c },
282+
MaybeEscapedCharacter { literal: c },
283283
// Ensure `len` behaves correctly.
284284
Self::CHAR_FLAG..(Self::CHAR_FLAG + 1),
285285
)
286286
}
287287

288288
#[inline]
289-
const fn is_unescaped(&self) -> bool {
289+
const fn is_literal(&self) -> bool {
290290
self.alive.start & Self::CHAR_FLAG != 0
291291
}
292292

293293
pub(crate) fn next(&mut self) -> Option<char> {
294294
let i = self.alive.next()?;
295295

296-
if self.is_unescaped() {
296+
if self.is_literal() {
297297
// SAFETY: We just checked that `self` contains a literal `char`.
298298
return Some(unsafe { self.as_char() });
299299
}
@@ -313,7 +313,7 @@ impl<const N: usize> fmt::Display for EscapeIterInner<N, AlwaysEscaped> {
313313

314314
impl<const N: usize> fmt::Display for EscapeIterInner<N, MaybeEscaped> {
315315
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
316-
if self.is_unescaped() {
316+
if self.is_literal() {
317317
// SAFETY: We just checked that `self` contains a literal `char`.
318318
f.write_char(unsafe { self.as_char() })
319319
} else {
@@ -335,7 +335,7 @@ impl<const N: usize> fmt::Debug for EscapeIterInner<N, AlwaysEscaped> {
335335
impl<const N: usize> fmt::Debug for EscapeIterInner<N, MaybeEscaped> {
336336
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
337337
let mut d = f.debug_tuple("EscapeIterInner");
338-
if self.is_unescaped() {
338+
if self.is_literal() {
339339
// SAFETY: We just checked that `self` contains a literal `char`.
340340
d.field(unsafe { &self.as_char() });
341341
} else {

0 commit comments

Comments
 (0)