mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 11:31:32 +11:00
Proper error handling if window create fail
This commit is contained in:
parent
867daf1ca9
commit
66c36fb6c6
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue