pub fn run<Err: std::fmt::Debug, F>(self, main_loop: F) -> !
    where
        F: FnMut(PlatformContext) -> std::result::Result<(), Err> + 'static,
    {
        let el = std::mem::replace(&mut *self.event_loop.borrow_mut(), None).unwrap();
        let mut main_loop = main_loop;
        let this = self.system.clone_handle();
        el.run(move |event, el, cf| {
            match &event {
                winit::event::Event::UserEvent(InternalEvent::QuitRequested) => {
                    *cf = winit::event_loop::ControlFlow::Exit
                }
                _ => *cf = winit::event_loop::ControlFlow::Poll,
            }

            match event::convert_winit_event(&this, event) {
                Some(system_event) => {
                    let ctx = PlatformContext {
                        main_thread_state: &self,
                        event_loop: Some(el),
                        triggering_event: system_event.clone(),
                    };

                    this.event_pub.dispatch(system_event);
                    this.update_windows();

                    main_loop(ctx).unwrap();
                }
                None => (),
            }
        })
    }
/// Starts the main even loop for this window system.
///
/// # Panics
///
/// If run has already been invoked, then this function will panic.
Starts the main even loop for this window system.
Starts the main even loop for this window system .
pub fn run<Err: std::fmt::Debug, F>(self, main_loop: F) -> !
    where
        F: FnMut(PlatformContext) -> std::result::Result<(), Err> + 'static,
    {
        let el = std::mem::replace(&mut *self.event_loop.borrow_mut(), None).unwrap();
        let mut main_loop = main_loop;
        let this = self.system.clone_handle();
        el.run(move |event, el, cf| {
            match &event {
                winit::event::Event::UserEvent(InternalEvent::QuitRequested) => {
                    *cf = winit::event_loop::ControlFlow::Exit
                }
                _ => *cf = winit::event_loop::ControlFlow::Poll,
            }
            match event::convert_winit_event(&this, event) {
                Some(system_event) => {
                    let ctx = PlatformContext {
                        main_thread_state: &self,
                        event_loop: Some(el),
                        triggering_event: system_event.clone(),
                    };
                    this.event_pub.dispatch(system_event);
                    this.update_windows();
                    main_loop(ctx).unwrap();
                }
                None => (),
            }
        })
    }
pub fn run < Err : std :: fmt :: Debug , F > ( self , main_loop : F ) -> ! where F : FnMut ( PlatformContext ) -> std :: result :: Result < ( ) , Err > + ' static , { let el = std :: mem :: replace ( & mut * self . event_loop . borrow_mut ( ) , None ) . unwrap ( ) ; let mut main_loop = main_loop ; let this = self . system . clone_handle ( ) ; el . run ( move | event , el , cf | { match & event { winit :: event :: Event :: UserEvent ( InternalEvent :: QuitRequested ) => { * cf = winit :: event_loop :: ControlFlow :: Exit } _ => * cf = winit :: event_loop :: ControlFlow :: Poll , } match event :: convert_winit_event ( & this , event ) { Some ( system_event ) => { let ctx = PlatformContext { main_thread_state : & self , event_loop : Some ( el ) , triggering_event : system_event . clone ( ) , } ; this . event_pub . dispatch ( system_event ) ; this . update_windows ( ) ; main_loop ( ctx ) . unwrap ( ) ; } None => ( ) , } } ) }
Starts the main even loop for this window system.
Starts the main even loop for this window system .
self
main_loop
F
self
main_loop
F
panics
If run has already been invoked, then this function will panic.
If run has already been invoked then this function will panic .