From 697d42a64f89e7c8e142d6f444eaa2dde3eb421b Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 26 Mar 2015 19:07:59 +0100 Subject: [PATCH] choose_pixel_format now returns a Result --- src/lib.rs | 4 ++-- src/win32/init.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7f404c36..aba67525 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -304,7 +304,7 @@ impl<'a> BuilderAttribs<'a> { (new_attribs, sharing) } - fn choose_pixel_format(&self, iter: I) -> (T, PixelFormat) + fn choose_pixel_format(&self, iter: I) -> Result<(T, PixelFormat), CreationError> where I: Iterator, T: Clone { let mut current_result = None; @@ -343,7 +343,7 @@ impl<'a> BuilderAttribs<'a> { } current_result.or(current_software_result) - .expect("Could not find compliant pixel format") + .ok_or(CreationError::NotSupported) } } diff --git a/src/win32/init.rs b/src/win32/init.rs index 5266ae4a..08d54c0e 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -136,7 +136,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, // getting the pixel format that we will use and setting it { let formats = enumerate_native_pixel_formats(&dummy_window); - let (id, _) = builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))); + let (id, _) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a)))); try!(set_pixel_format(&dummy_window, id)); } @@ -206,7 +206,7 @@ unsafe fn init(title: Vec, builder: BuilderAttribs<'static>, enumerate_native_pixel_formats(&real_window) }; - let (id, _) = builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a))); + let (id, _) = try!(builder.choose_pixel_format(formats.into_iter().map(|(a, b)| (b, a)))); try!(set_pixel_format(&real_window, id)); }