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 window = Window::new("Noise Test - Press ESC to exit",
WIDTH,
HEIGHT,
Scale::X2)
.unwrap();
let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X2) {
Ok(win) => win,
Err(err) => {
println!("Unable to create window {}", err);
return;
}
};
while window.is_open() && !window.is_key_down(Key::Escape) {
for i in buffer.iter_mut() {