mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Tweak MapPassErr to work for both errors and results (#7780)
This commit is contained in:
parent
54d30da44a
commit
24f779696b
@ -1519,15 +1519,15 @@ impl RenderBundleError {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> MapPassErr<T, RenderBundleError> for Result<T, E>
|
||||
impl<E> MapPassErr<RenderBundleError> for E
|
||||
where
|
||||
E: Into<RenderBundleErrorInner>,
|
||||
{
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, RenderBundleError> {
|
||||
self.map_err(|inner| RenderBundleError {
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> RenderBundleError {
|
||||
RenderBundleError {
|
||||
scope,
|
||||
inner: inner.into(),
|
||||
})
|
||||
inner: self.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -182,15 +182,15 @@ pub struct ComputePassError {
|
||||
pub(super) inner: ComputePassErrorInner,
|
||||
}
|
||||
|
||||
impl<T, E> MapPassErr<T, ComputePassError> for Result<T, E>
|
||||
impl<E> MapPassErr<ComputePassError> for E
|
||||
where
|
||||
E: Into<ComputePassErrorInner>,
|
||||
{
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, ComputePassError> {
|
||||
self.map_err(|inner| ComputePassError {
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> ComputePassError {
|
||||
ComputePassError {
|
||||
scope,
|
||||
inner: inner.into(),
|
||||
})
|
||||
inner: self.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1029,8 +1029,17 @@ impl Default for BindGroupStateChange {
|
||||
}
|
||||
}
|
||||
|
||||
trait MapPassErr<T, O> {
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, O>;
|
||||
trait MapPassErr<T> {
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> T;
|
||||
}
|
||||
|
||||
impl<T, E, F> MapPassErr<Result<T, F>> for Result<T, E>
|
||||
where
|
||||
E: MapPassErr<F>,
|
||||
{
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, F> {
|
||||
self.map_err(|err| err.map_pass_err(scope))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
||||
@ -807,15 +807,12 @@ pub struct RenderPassError {
|
||||
pub(super) inner: RenderPassErrorInner,
|
||||
}
|
||||
|
||||
impl<T, E> MapPassErr<T, RenderPassError> for Result<T, E>
|
||||
where
|
||||
E: Into<RenderPassErrorInner>,
|
||||
{
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> Result<T, RenderPassError> {
|
||||
self.map_err(|inner| RenderPassError {
|
||||
impl<E: Into<RenderPassErrorInner>> MapPassErr<RenderPassError> for E {
|
||||
fn map_pass_err(self, scope: PassErrorScope) -> RenderPassError {
|
||||
RenderPassError {
|
||||
scope,
|
||||
inner: inner.into(),
|
||||
})
|
||||
inner: self.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user