diff options
author | 2020-09-08 00:35:17 +0200 | |
---|---|---|
committer | 2020-09-08 00:44:59 +0200 | |
commit | c1f79b40cf704cafc807250b177fc7d3444fe54f (patch) | |
tree | 31c0cf2b8d166976dc819f020e0185f9d8c2bdcd /wgpu | |
parent | faa12382d4d7a44ab60fa5bf2a5024a34dbb2e8d (diff) | |
download | iced-c1f79b40cf704cafc807250b177fc7d3444fe54f.tar.gz iced-c1f79b40cf704cafc807250b177fc7d3444fe54f.tar.bz2 iced-c1f79b40cf704cafc807250b177fc7d3444fe54f.zip |
Make `Application` and `Sandbox` return a `Result`
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/lib.rs | 4 | ||||
-rw-r--r-- | wgpu/src/window/compositor.rs | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 570e8a94..5f44dd91 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -36,7 +36,9 @@ mod backend; mod quad; mod text; -pub use iced_graphics::{Antialiasing, Color, Defaults, Primitive, Viewport}; +pub use iced_graphics::{ + Antialiasing, Color, Defaults, Error, Primitive, Viewport, +}; pub use wgpu; pub use backend::Backend; diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index c790f35f..79ffacdd 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -1,7 +1,6 @@ -use crate::{Backend, Color, Renderer, Settings}; +use crate::{Backend, Color, Error, Renderer, Settings, Viewport}; use futures::task::SpawnExt; -use iced_graphics::Viewport; use iced_native::{futures, mouse}; use raw_window_handle::HasRawWindowHandle; @@ -82,13 +81,13 @@ impl iced_graphics::window::Compositor for Compositor { type Surface = wgpu::Surface; type SwapChain = wgpu::SwapChain; - fn new(settings: Self::Settings) -> (Self, Renderer) { + fn new(settings: Self::Settings) -> Result<(Self, Renderer), Error> { let compositor = futures::executor::block_on(Self::request(settings)) - .expect("Could not find a suitable graphics adapter"); + .ok_or(Error::AdapterNotFound)?; let backend = compositor.create_backend(); - (compositor, Renderer::new(backend)) + Ok((compositor, Renderer::new(backend))) } fn create_surface<W: HasRawWindowHandle>( |