mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Panic to prevent arena Handle overflow (#667)
* Panic to prevent arena Handle overflow * Use `NonZeroU32::new` to detect overflow
This commit is contained in:
@@ -189,7 +189,8 @@ impl<T> Arena<T> {
|
||||
/// Adds a new value to the arena, returning a typed handle.
|
||||
pub fn append(&mut self, value: T) -> Handle<T> {
|
||||
let position = self.data.len() + 1;
|
||||
let index = unsafe { Index::new_unchecked(position as u32) };
|
||||
let index =
|
||||
Index::new(position as u32).expect("Failed to append to Arena. Handle overflows");
|
||||
self.data.push(value);
|
||||
Handle::new(index)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user