ironrdp_core/
as_any.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use core::any::Any;

/// Implement [`AsAny`] for the given type.
#[macro_export]
macro_rules! impl_as_any {
    ($t:ty) => {
        impl $crate::AsAny for $t {
            #[inline]
            fn as_any(&self) -> &dyn core::any::Any {
                self
            }

            #[inline]
            fn as_any_mut(&mut self) -> &mut dyn core::any::Any {
                self
            }
        }
    };
}

/// Type information (`TypeId`) may be retrieved at runtime for this type.
pub trait AsAny: 'static {
    /// Returns a reference to the type information for this type.
    fn as_any(&self) -> &dyn Any;

    /// Returns a mutable reference to the type information for this type.
    fn as_any_mut(&mut self) -> &mut dyn Any;
}