Trait cpp_utils::DynamicCast
[−]
[src]
pub trait DynamicCast<T> { fn dynamic_cast(&self) -> Option<&T>; fn dynamic_cast_mut(&mut self) -> Option<&mut T>; }
Provides access to C++ dynamic_cast
conversion.
This trait is automatically implemented by cpp_to_rust
.
If T1
class is derived (in C++) from T2
class,
DynamicCast<T1>
is implemented for T2
.
Use StaticCast
to convert from T1
to T2
.
DynamicCast
allows to convert a reference to a class into
a reference to a derived class with a runtime check of the type.
Conversion returns None
if the object is actually not an instance of
the target type.
dynamic_cast
and dynamic_cast_mut
free functions can be used
to convert pointer types.
Required Methods
fn dynamic_cast(&self) -> Option<&T>
Convert type of a const reference.
Returns None
if self
is not an instance of T
.
fn dynamic_cast_mut(&mut self) -> Option<&mut T>
Convert type of a mutable reference.
Returns None
if self
is not an instance of T
.