docs: add fn main to root examples
This is not strictly required, but makes the examples a bit easier to read understand (especially since the `EventLoop` really _should_ be created inside `fn main`, and not in some random function potentially running on a random thread).
This commit is contained in:
parent
3a60cbaba5
commit
74958ecc6f
1 changed files with 19 additions and 11 deletions
|
|
@ -7,7 +7,12 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use winit::event_loop::EventLoop;
|
//! use winit::event_loop::EventLoop;
|
||||||
|
//!
|
||||||
|
//! # // Intentionally use `fn main` for clarity
|
||||||
|
//! fn main() {
|
||||||
//! let event_loop = EventLoop::new().unwrap();
|
//! let event_loop = EventLoop::new().unwrap();
|
||||||
|
//! // ...
|
||||||
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Then you create a [`Window`] with [`create_window`].
|
//! Then you create a [`Window`] with [`create_window`].
|
||||||
|
|
@ -83,6 +88,8 @@
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
//! # // Intentionally use `fn main` for clarity
|
||||||
|
//! fn main() {
|
||||||
//! let event_loop = EventLoop::new().unwrap();
|
//! let event_loop = EventLoop::new().unwrap();
|
||||||
//!
|
//!
|
||||||
//! // ControlFlow::Poll continuously runs the event loop, even if the OS hasn't
|
//! // ControlFlow::Poll continuously runs the event loop, even if the OS hasn't
|
||||||
|
|
@ -96,6 +103,7 @@
|
||||||
//!
|
//!
|
||||||
//! let mut app = App::default();
|
//! let mut app = App::default();
|
||||||
//! event_loop.run_app(&mut app);
|
//! event_loop.run_app(&mut app);
|
||||||
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! [`WindowEvent`] has a [`WindowId`] member. In multi-window environments, it should be
|
//! [`WindowEvent`] has a [`WindowId`] member. In multi-window environments, it should be
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue