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
|
|
@ -12,7 +12,7 @@ use std::ops::Deref;
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::utils::AsAny;
|
||||
use crate::utils::{impl_dyn_casting, AsAny};
|
||||
|
||||
/// Handle to a monitor.
|
||||
///
|
||||
|
|
@ -148,6 +148,8 @@ impl PartialEq for dyn MonitorHandleProvider + '_ {
|
|||
|
||||
impl Eq for dyn MonitorHandleProvider + '_ {}
|
||||
|
||||
impl_dyn_casting!(MonitorHandleProvider);
|
||||
|
||||
/// Describes a fullscreen video mode of a monitor.
|
||||
///
|
||||
/// Can be acquired with [`MonitorHandleProvider::video_modes`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue