Crate inspect_type
source ·Expand description
Macro to answer the question: does it implement a trait?
Module :: inspect_type
Diagnostic-purpose tools to inspect type of a variable and its size.
Basic use-case.
#![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ]
pub use inspect_type::*;
#[ cfg( feature = "nightly" ) ]
{
inspect_type_of!( &[ 1, 2, 3 ][ .. ] );
// < sizeof( &[1, 2, 3][..] : &[i32] ) = 16
inspect_type_of!( &[ 1, 2, 3 ] );
// < sizeof( &[1, 2, 3] : &[i32; 3] ) = 8
}
To add to your project
cargo add implements
Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/inspect_type_trivial
cargo run
Modules
- Exposed namespace of the module.
- Orphan namespace of the module.
- Prelude to use essentials:
use my_module::prelude::*. - Protected namespace of the module.
Macros
- Macro
implementsto answer the question: does it implement a trait? - Macro
instance_ofto answer the question: does it implement a trait? Alias of the macroimplements.