* Replace bespoke Error impl with `thiserror`

* cargo update

* Finix winit version in dev-dependencies
This commit is contained in:
Jay Oster 2020-03-17 20:36:08 -07:00 committed by GitHub
parent 7701ac2d0e
commit b38363a602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 329 additions and 353 deletions

655
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,7 @@ travis-ci = { repository = "parasyte/pixels" }
maintenance = { status = "actively-developed" }
[dependencies]
thiserror = "1.0"
wgpu = "0.4"
# These are only used by the examples, and enabled with features
@ -36,12 +37,12 @@ line_drawing = { version = "0.8", optional = true }
log = { version = "0.4", features = ["release_max_level_warn"], optional = true }
randomize = { version = "3.0", optional = true }
simple-invaders = { path = "simple-invaders", optional = true }
winit = { version = "0.20.0-alpha4", optional = true }
winit_input_helper = { version = "0.4.0-alpha4", optional = true }
winit = { version = "=0.20.0-alpha4", optional = true }
winit_input_helper = { version = "=0.4.0-alpha4", optional = true }
[dev-dependencies]
pixels-mocks = { path = "pixels-mocks" }
winit = "0.20.0-alpha4"
winit = "=0.20.0-alpha4"
[[example]]
name = "conway"

View file

@ -13,13 +13,12 @@
#![forbid(unsafe_code)]
use std::cell::RefCell;
use std::error::Error as StdError;
use std::fmt;
use std::rc::Rc;
pub use crate::macros::*;
pub use crate::render_pass::{BoxedRenderPass, Device, Queue, RenderPass};
use crate::renderers::Renderer;
use thiserror::Error;
pub use wgpu;
use wgpu::{Extent3d, TextureView};
@ -71,9 +70,10 @@ pub struct PixelsBuilder {
}
/// All the ways in which creating a pixel buffer can fail.
#[derive(Debug)]
#[derive(Error, Debug)]
pub enum Error {
/// No suitable [`wgpu::Adapter`] found
#[error("No suitable `wgpu::Adapter` found")]
AdapterNotFound,
}
@ -489,20 +489,6 @@ impl PixelsBuilder {
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl StdError for Error {
fn description(&self) -> &str {
match self {
Error::AdapterNotFound => "No suitable Adapter found",
}
}
}
fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> u32 {
match texture_format {
// 8-bit formats