Propagate error from EventLoop creation

Inner panics could make it hard to trouble shoot the issues and for some
users ints not desirable.

The inner panics were left only when they are used to `assert!` during
development.
This commit is contained in:
Kirill Chibisov 2023-08-06 06:03:54 +04:00 committed by GitHub
parent 584aab4cd0
commit ed26dd58fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 344 additions and 291 deletions

View file

@ -1,16 +1,18 @@
use std::marker::PhantomData;
use crate::error::EventLoopError;
use crate::event::Event;
use crate::event_loop::{ControlFlow, EventLoopWindowTarget as RootEventLoopWindowTarget};
use super::{backend, device, window};
mod proxy;
pub(crate) mod runner;
mod state;
mod window_target;
pub use self::proxy::EventLoopProxy;
pub use self::window_target::EventLoopWindowTarget;
use super::{backend, device, window};
use crate::event::Event;
use crate::event_loop::{ControlFlow, EventLoopWindowTarget as RootEventLoopWindowTarget};
use std::marker::PhantomData;
pub use proxy::EventLoopProxy;
pub use window_target::EventLoopWindowTarget;
pub struct EventLoop<T: 'static> {
elw: RootEventLoopWindowTarget<T>,
@ -20,13 +22,13 @@ pub struct EventLoop<T: 'static> {
pub(crate) struct PlatformSpecificEventLoopAttributes {}
impl<T> EventLoop<T> {
pub(crate) fn new(_: &PlatformSpecificEventLoopAttributes) -> Self {
EventLoop {
pub(crate) fn new(_: &PlatformSpecificEventLoopAttributes) -> Result<Self, EventLoopError> {
Ok(EventLoop {
elw: RootEventLoopWindowTarget {
p: EventLoopWindowTarget::new(),
_marker: PhantomData,
},
}
})
}
pub fn run<F>(self, mut event_handler: F) -> !