Skip to content

Commit 269ce89

Browse files
authored
Apply suggestions from code review
1 parent 99986c7 commit 269ce89

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

library/core/src/escape.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const fn escape_unicode<const N: usize>(c: char) -> ([ascii::Char; N], Range<u8>
153153

154154
#[derive(Clone, Copy)]
155155
union MaybeEscapedCharacter<const N: usize> {
156-
pub escaped: [ascii::Char; N],
156+
pub escape_seq: [ascii::Char; N],
157157
pub literal: char,
158158
}
159159

@@ -197,35 +197,35 @@ impl<const N: usize, ESCAPING> EscapeIterInner<N, ESCAPING> {
197197

198198
pub(crate) const fn backslash(c: ascii::Char) -> Self {
199199
let (data, range) = backslash(c);
200-
Self::new(MaybeEscapedCharacter { escaped: data }, range)
200+
Self::new(MaybeEscapedCharacter { escape_seq: data }, range)
201201
}
202202

203203
pub(crate) const fn ascii(c: u8) -> Self {
204204
let (data, range) = escape_ascii(c);
205-
Self::new(MaybeEscapedCharacter { escaped: data }, range)
205+
Self::new(MaybeEscapedCharacter { escape_seq: data }, range)
206206
}
207207

208208
pub(crate) const fn unicode(c: char) -> Self {
209209
let (data, range) = escape_unicode(c);
210-
Self::new(MaybeEscapedCharacter { escaped: data }, range)
210+
Self::new(MaybeEscapedCharacter { escape_seq: data }, range)
211211
}
212212

213213
#[inline]
214214
pub(crate) const fn empty() -> Self {
215-
Self::new(MaybeEscapedCharacter { escaped: [ascii::Char::Null; N] }, 0..0)
215+
Self::new(MaybeEscapedCharacter { escape_seq: [ascii::Char::Null; N] }, 0..0)
216216
}
217217

218218
/// # Safety
219219
///
220220
/// The caller must ensure that `self` contains an escape sequence.
221221
#[inline]
222222
unsafe fn as_ascii(&self) -> &[ascii::Char] {
223-
// SAFETY: `self.data.escaped` contains an escape sequence, as is guaranteed
223+
// SAFETY: `self.data.escape_seq` contains an escape sequence, as is guaranteed
224224
// by the caller, and `self.alive` is guaranteed to be a valid range for
225225
// indexing `self.data`.
226226
unsafe {
227227
self.data
228-
.escaped
228+
.escape_seq
229229
.get_unchecked(usize::from(self.alive.start)..usize::from(self.alive.end))
230230
}
231231
}
@@ -259,16 +259,16 @@ impl<const N: usize> EscapeIterInner<N, AlwaysEscaped> {
259259
let i = self.alive.next()?;
260260

261261
// SAFETY: The `AlwaysEscaped` marker guarantees that `self` contains an escape sequence,
262-
// and `i` is guaranteed to be a valid index for `self.data.escaped`.
263-
unsafe { Some(self.data.escaped.get_unchecked(usize::from(i)).to_u8()) }
262+
// and `i` is guaranteed to be a valid index for `self.data.escape_seq`.
263+
unsafe { Some(self.data.escape_seq.get_unchecked(usize::from(i)).to_u8()) }
264264
}
265265

266266
pub(crate) fn next_back(&mut self) -> Option<u8> {
267267
let i = self.alive.next_back()?;
268268

269269
// SAFETY: We just checked that `self` contains an escape sequence, and
270-
// `i` is guaranteed to be a valid index for `self.data.escaped`.
271-
unsafe { Some(self.data.escaped.get_unchecked(usize::from(i)).to_u8()) }
270+
// `i` is guaranteed to be a valid index for `self.data.escape_seq`.
271+
unsafe { Some(self.data.escape_seq.get_unchecked(usize::from(i)).to_u8()) }
272272
}
273273
}
274274

@@ -299,8 +299,8 @@ impl<const N: usize> EscapeIterInner<N, MaybeEscaped> {
299299
}
300300

301301
// SAFETY: We just checked that `self` contains an escape sequence, and
302-
// `i` is guaranteed to be a valid index for `self.data.escaped`.
303-
Some(char::from(unsafe { self.data.escaped.get_unchecked(usize::from(i)).to_u8() }))
302+
// `i` is guaranteed to be a valid index for `self.data.escape_seq`.
303+
Some(char::from(unsafe { self.data.escape_seq.get_unchecked(usize::from(i)).to_u8() }))
304304
}
305305
}
306306

0 commit comments

Comments
 (0)