With the overviews done, let's look at the standard modules.
This module enables the dynamic casting of 'static
via runtime reflection.
Note
It can be used to obtain a TypeId
. When used as a borrowed trait reference (&Any
), it can be used to determine whether the value is a given type (using Is
) and also to get a reference to the inner value as a type (using downcast_ref
). &mut Any
will allow access to downcast_mut
, which obtains the mutable reference to the inner value. &Any
can only be used for testing a specific type and cannot be used to test whether a type implements a trait.
Structs
TypeId
:TypeId
is an opaque object that cannot be examined, but does allow for clone, compare, print, and show. Only available for types that use'static
.
Implement
of<T>() -> TypeId where T:’static + Reflect + ?Sized
: This returns theTypeId
of the typeT
the function was instantiated with.
Traits
pub trait Any: 'static + Reflect {fn get_type_id(&self) ->...