utils: add cast_* methods to allow more type-safe casting
Relying on just `as_any` was error prone and will become redundant in the future, once upcasting will be stable, we also won't to impose a restriction on to which concrete type we're casting, since casting to a type that doesn't implement a base trait doesn't make much sense. Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
This commit is contained in:
parent
5cada36ae8
commit
16d5f46db1
19 changed files with 158 additions and 136 deletions
|
|
@ -25,7 +25,7 @@ use crate::application::ApplicationHandler;
|
|||
use crate::error::{EventLoopError, RequestError};
|
||||
use crate::monitor::MonitorHandle;
|
||||
use crate::platform_impl;
|
||||
use crate::utils::AsAny;
|
||||
use crate::utils::{impl_dyn_casting, AsAny};
|
||||
use crate::window::{CustomCursor, CustomCursorSource, Theme, Window, WindowAttributes};
|
||||
|
||||
/// Provides a way to retrieve events from the system and from the windows that were registered to
|
||||
|
|
@ -406,6 +406,8 @@ impl HasDisplayHandle for dyn ActiveEventLoop + '_ {
|
|||
}
|
||||
}
|
||||
|
||||
impl_dyn_casting!(ActiveEventLoop);
|
||||
|
||||
/// A proxy for the underlying display handle.
|
||||
///
|
||||
/// The purpose of this type is to provide a cheaply cloneable handle to the underlying
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue