From b8c6afb96a5850adb54e71c638a399f13087d467 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Sun, 21 May 2017 22:03:22 -0700 Subject: [PATCH] Update README example to use EventsLoop --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d6d66853..29f690a4 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,16 @@ another library. extern crate winit; fn main() { - let window = winit::Window::new().unwrap(); + let events_loop = winit::EventsLoop::new(); + let window = winit::Window::new(&events_loop).unwrap(); - for event in window.wait_events() { + events_loop.run_forever(|event| { match event { - winit::Event::Closed => break, + winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => { + events_loop.interrupt(); + }, _ => () } - } + }); } ```