refactor(data_structures): add debug assertion to SparseStack (#6218)

Just add an additional debug assert.
This commit is contained in:
overlookmotel 2024-10-01 12:26:37 +00:00
parent adc538141c
commit 61805fd3f2

View file

@ -175,6 +175,7 @@ impl<T> SparseStack<T> {
self.values.push(init());
}
debug_assert!(!self.values.is_empty());
// SAFETY: Last `self.has_values` is only `true` if there's a corresponding value in `self.values`.
// This invariant is maintained in `push`, `pop`, `take_last`, and `last_or_init`.
// Here either last `self.has_values` was already `true`, or it's just been set to `true`