This module enables the dynamic casting of 'static via runtime reflection.
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 the TypeId of the type T the function was instantiated with.
Traits
- pub trait Any: 'static + Reflect {fn get_type_id(&self) -> TypeId;}: Emulates dynamic typing.
Trait methods
- impl Any + 'static
- is<T>(&self) -> bool where T:Any: Returns true if the boxed type is the same as T
- downcast_ref<T>(&self) -> Option<&T> where T:Any: Returns ref to the boxed value whether it is of type T or None
- downcast_mut<T>(&mut self) -> Option<&mut T> where T:Any: As for downcast_ref but returns a mutable ref or None
- impl Any + 'static + Send
- is<T>(&self) -> bool where T:Any: Sends to the method defined on the type Any
- downcast_ref<T>(&self) -> Option<&T> where T:Any: Sends to the method defined on the type Any
- downcast_mut<T>(&mut self) -> Option<&mut T> where T:Any: Sends to the method defined on the type Any
Trait implementations
- impl Debug for Any + ‘static
- fmt(&self, f: &mut Formatter) -> Result<(), Error>: Format the value using the formatter
- impl Debug for Any + ‘static + Send
-
fmt(&self, f: &mut Formatter) -> Result<(), Error>: Sends to the method defined on the Debug method
-