Skip to content

Commit bec8fee

Browse files
committed
refactor(data_structures)!: rename Stack::last_unchecked_mut method (oxc-project#8911)
Rename `Stack::last_mut_unchecked` to `Stack::last_unchecked_mut`. This matches `std`'s naming convention e.g. `get_unchecked_mut` on slices.
1 parent 0a74cf5 commit bec8fee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/oxc_data_structures/src/stack/sparse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<T> SparseStack<T> {
177177
debug_assert!(!self.values.is_empty());
178178
// SAFETY: Last `self.has_values` is only `true` if there's a corresponding value in `self.values`.
179179
// This invariant is maintained in `push`, `pop`, `take_last`, `last_or_init`, and `last_mut_or_init`.
180-
let value = unsafe { self.values.last_mut_unchecked() };
180+
let value = unsafe { self.values.last_unchecked_mut() };
181181
Some(value)
182182
} else {
183183
None
@@ -236,7 +236,7 @@ impl<T> SparseStack<T> {
236236
// This invariant is maintained in `push`, `pop`, `take_last`, and `last_or_init`.
237237
// Here either last `self.has_values` was already `true`, or it's just been set to `true`
238238
// and a value pushed to `self.values` above.
239-
unsafe { self.values.last_mut_unchecked() }
239+
unsafe { self.values.last_unchecked_mut() }
240240
}
241241

242242
/// Get number of entries on the stack.

crates/oxc_data_structures/src/stack/standard.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<T> Stack<T> {
224224
#[expect(clippy::if_not_else)]
225225
if !self.is_empty() {
226226
// SAFETY: Stack is not empty
227-
Some(unsafe { self.last_mut_unchecked() })
227+
Some(unsafe { self.last_unchecked_mut() })
228228
} else {
229229
None
230230
}
@@ -236,7 +236,7 @@ impl<T> Stack<T> {
236236
///
237237
/// * Stack must not be empty.
238238
#[inline]
239-
pub unsafe fn last_mut_unchecked(&mut self) -> &mut T {
239+
pub unsafe fn last_unchecked_mut(&mut self) -> &mut T {
240240
debug_assert!(self.end > self.start);
241241
debug_assert!(self.cursor > self.start);
242242
debug_assert!(self.cursor <= self.end);

0 commit comments

Comments
 (0)