Add Send + Sync bounds for user-defined errors (#197)

- This enables compatibility with anyhow and the async ecosystem
This commit is contained in:
Jay Oster 2021-09-04 14:41:43 -07:00 committed by GitHub
parent db00a67c60
commit 50c77a5f83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,9 +117,11 @@ pub enum Error {
Surface(wgpu::SurfaceError), Surface(wgpu::SurfaceError),
/// User-defined error from custom render function /// User-defined error from custom render function
#[error("User-defined error.")] #[error("User-defined error.")]
UserDefined(#[from] Box<dyn std::error::Error>), UserDefined(#[from] DynError),
} }
type DynError = Box<dyn std::error::Error + Send + Sync + 'static>;
impl<'win, W: HasRawWindowHandle> SurfaceTexture<'win, W> { impl<'win, W: HasRawWindowHandle> SurfaceTexture<'win, W> {
/// Create a logical texture for a window surface. /// Create a logical texture for a window surface.
/// ///
@ -357,7 +359,7 @@ impl Pixels {
&mut wgpu::CommandEncoder, &mut wgpu::CommandEncoder,
&wgpu::TextureView, &wgpu::TextureView,
&PixelsContext, &PixelsContext,
) -> Result<(), Box<dyn std::error::Error>>, ) -> Result<(), DynError>,
{ {
let frame = self let frame = self
.context .context