This commit is contained in:
Daniel Collin 2020-09-16 08:40:27 +02:00
parent 2646964b9e
commit 8de1d5718d

View file

@ -8,7 +8,7 @@ const HEIGHT: usize = 360;
type KeyVec = Rc<RefCell<Vec<u32>>>; type KeyVec = Rc<RefCell<Vec<u32>>>;
struct Input { struct Input {
keys: KeyVec, keys: KeyVec,
} }
impl Input { impl Input {
@ -27,14 +27,14 @@ fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT]; let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = Window::new( let mut window = Window::new(
"Test - ESC to exit", "Test - ESC to exit",
WIDTH, WIDTH,
HEIGHT, HEIGHT,
WindowOptions::default(), WindowOptions::default(),
) )
.unwrap_or_else(|e| { .unwrap_or_else(|e| {
panic!("{}", e); panic!("{}", e);
}); });
let keys_data = KeyVec::new(RefCell::new(Vec::new())); let keys_data = KeyVec::new(RefCell::new(Vec::new()));
@ -50,9 +50,7 @@ fn main() {
} }
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way // We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window window.update_with_buffer(&buffer, WIDTH, HEIGHT).unwrap();
.update_with_buffer(&buffer, WIDTH, HEIGHT)
.unwrap();
let mut keys = keys_data.borrow_mut(); let mut keys = keys_data.borrow_mut();