Proper error handling if window create fail

This commit is contained in:
Daniel Collin 2016-01-02 19:40:41 +01:00
parent 867daf1ca9
commit 66c36fb6c6

View file

@ -12,11 +12,13 @@ fn main() {
let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT];
let mut window = Window::new("Noise Test - Press ESC to exit", let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X2) {
WIDTH, Ok(win) => win,
HEIGHT, Err(err) => {
Scale::X2) println!("Unable to create window {}", err);
.unwrap(); return;
}
};
while window.is_open() && !window.is_key_down(Key::Escape) { while window.is_open() && !window.is_key_down(Key::Escape) {
for i in buffer.iter_mut() { for i in buffer.iter_mut() {