mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-26 01:11:22 +01:00
Fix regression in device_create_swap_chain
It was caused by new behavior of Storage::remove.
This commit is contained in:
1 parent
8ce2530b69
commit
c3a5144ae0
1 file changed
+10
-4
+10
-4
@@ -183,13 +183,19 @@ impl<T, I: TypedId> Storage<T, I> {
|
||||
}
|
||||
}
|
||||
|
||||
//Prevents panic on out of range access.
|
||||
// Prevents panic on out of range access, allows Vacant elements.
|
||||
pub(crate) fn try_remove(&mut self, id: I) -> Option<T> {
|
||||
let (index, epoch, backend) = id.unzip();
|
||||
let (index, epoch, _) = id.unzip();
|
||||
if index as usize >= self.map.len() {
|
||||
return None;
|
||||
None
|
||||
} else if let Element::Occupied(value, storage_epoch) =
|
||||
std::mem::replace(&mut self.map[index as usize], Element::Vacant)
|
||||
{
|
||||
assert_eq!(epoch, storage_epoch);
|
||||
Some(value)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.remove(I::zip(index, epoch, backend))
|
||||
}
|
||||
|
||||
pub(crate) fn iter(&self, backend: Backend) -> impl Iterator<Item = (I, &T)> {
|
||||
|
||||
Reference in new issue
Block a user