mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
[core] Use expect
instead of "if let else panic". (#5513)
Use `Option::expect` to check the result from `Arc::into_inner`, rather than `if let Some ... else panic!`.
This commit is contained in:
parent
82dead09e4
commit
f8deb0317f
@ -286,11 +286,9 @@ impl<A: HalApi> CommandBuffer<A> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_arc_into_baked(self: Arc<Self>) -> BakedCommands<A> {
|
pub(crate) fn from_arc_into_baked(self: Arc<Self>) -> BakedCommands<A> {
|
||||||
if let Some(mut command_buffer) = Arc::into_inner(self) {
|
let mut command_buffer = Arc::into_inner(self)
|
||||||
command_buffer.extract_baked_commands()
|
.expect("CommandBuffer cannot be destroyed because is still in use");
|
||||||
} else {
|
command_buffer.extract_baked_commands()
|
||||||
panic!("CommandBuffer cannot be destroyed because is still in use");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,13 +1210,10 @@ impl Global {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !cmdbuf.is_finished() {
|
if !cmdbuf.is_finished() {
|
||||||
if let Some(cmdbuf) = Arc::into_inner(cmdbuf) {
|
let cmdbuf = Arc::into_inner(cmdbuf).expect(
|
||||||
device.destroy_command_buffer(cmdbuf);
|
"Command buffer cannot be destroyed because is still in use",
|
||||||
} else {
|
);
|
||||||
panic!(
|
device.destroy_command_buffer(cmdbuf);
|
||||||
"Command buffer cannot be destroyed because is still in use"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +155,9 @@ impl Drop for Global {
|
|||||||
// destroy surfaces
|
// destroy surfaces
|
||||||
for element in surfaces_locked.map.drain(..) {
|
for element in surfaces_locked.map.drain(..) {
|
||||||
if let Element::Occupied(arc_surface, _) = element {
|
if let Element::Occupied(arc_surface, _) = element {
|
||||||
if let Some(surface) = Arc::into_inner(arc_surface) {
|
let surface = Arc::into_inner(arc_surface)
|
||||||
self.instance.destroy_surface(surface);
|
.expect("Surface cannot be destroyed because is still in use");
|
||||||
} else {
|
self.instance.destroy_surface(surface);
|
||||||
panic!("Surface cannot be destroyed because is still in use");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,22 +667,19 @@ impl Global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let surface = self.surfaces.unregister(id);
|
let surface = self.surfaces.unregister(id);
|
||||||
if let Some(surface) = Arc::into_inner(surface.unwrap()) {
|
let surface = Arc::into_inner(surface.unwrap())
|
||||||
if let Some(present) = surface.presentation.lock().take() {
|
.expect("Surface cannot be destroyed because is still in use");
|
||||||
#[cfg(vulkan)]
|
if let Some(present) = surface.presentation.lock().take() {
|
||||||
unconfigure::<hal::api::Vulkan>(self, &surface.raw, &present);
|
#[cfg(vulkan)]
|
||||||
#[cfg(metal)]
|
unconfigure::<hal::api::Vulkan>(self, &surface.raw, &present);
|
||||||
unconfigure::<hal::api::Metal>(self, &surface.raw, &present);
|
#[cfg(metal)]
|
||||||
#[cfg(dx12)]
|
unconfigure::<hal::api::Metal>(self, &surface.raw, &present);
|
||||||
unconfigure::<hal::api::Dx12>(self, &surface.raw, &present);
|
#[cfg(dx12)]
|
||||||
#[cfg(gles)]
|
unconfigure::<hal::api::Dx12>(self, &surface.raw, &present);
|
||||||
unconfigure::<hal::api::Gles>(self, &surface.raw, &present);
|
#[cfg(gles)]
|
||||||
}
|
unconfigure::<hal::api::Gles>(self, &surface.raw, &present);
|
||||||
|
|
||||||
self.instance.destroy_surface(surface);
|
|
||||||
} else {
|
|
||||||
panic!("Surface cannot be destroyed because is still in use");
|
|
||||||
}
|
}
|
||||||
|
self.instance.destroy_surface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumerate<A: HalApi>(
|
fn enumerate<A: HalApi>(
|
||||||
|
Loading…
Reference in New Issue
Block a user