Expand description
§Module :: reflect_tools
Runtime type reflection system providing traits, descriptors, and utilities for dynamic inspection of Rust types. Enables introspection of type names, sizes, elements, and structure at runtime without compile-time knowledge of the concrete type.
§Basic use-case
use reflect_tools::*;
let value = vec![ 1i32, 2, 3 ];
let entity = reflect( &value );
println!( "{}", entity.type_name() ); // "Vec"
println!( "{}", entity.len() ); // 3
println!( "{}", entity.is_container() ); // true
for kv in entity.elements()
{
println!( "{:?}", kv );
}§To add to your project
cargo add reflect_tools§Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/reflect_tools_trivial
cargo runModules§
- dependency
- Namespace with dependencies.
- exposed
- Exposed namespace of the module.
- orphan
- Orphan namespace of the module.
- own
- Own namespace of the module.
- prelude
- Prelude to use essentials:
use my_module::prelude::*. - reflect
- System of Types for Reflection
Structs§
- KeyVal
- Represents a key-value pair where the key is a static string slice
and the value is a boxed entity that implements the
AnyEntitytrait. - Optional
Cow - Universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type.
Traits§
- Entity
- The
Entitytrait defines a common interface for entities within a system, enabling runtime reflection, inspection, and manipulation of their properties and elements. It serves as a foundational component for dynamic entity handling, where entities can represent data structures, components, or other logical units with introspectable and manipulable state. - Fields
- A trait for iterating over fields convertible to a specified type within an entity.
- Iterator
Trait - A trait for iterators that implement
_IteratorTraitandClone. - _Iterator
Trait - A trait for iterators that are also
ExactSizeIterator.
Functions§
- reflect
- Provides a reflection of an instance that implements the
Instancetrait.