Crates.io | instance_of |
lib.rs | instance_of |
version | 0.1.0 |
source | src |
created_at | 2021-11-29 14:12:24.258207 |
updated_at | 2022-01-10 14:46:40.781322 |
description | Macro to answer the question: does it implement a trait? |
homepage | https://github.com/Wandalen/wTools/tree/master/module/rust/instance_of |
repository | https://github.com/Wandalen/wTools/tree/master/module/rust/instance_of |
max_upload_size | |
id | 489262 |
size | 5,973 |
Macro to answer the question: does it implement a trait?
This solution has a limitation:
Fn
/FnMut
/FnOnce
which current entity does not implement you will get compile-time error instead of false
.This is alias for module::implements.
use instance_of::*;
dbg!( instance_of!( 13_i32 => Copy ) );
// < instance_of!( 13_i32 => Copy ) : true
dbg!( instance_of!( Box::new( 13_i32 ) => Copy ) );
// < instance_of!( 13_i32 => Copy ) : false
cargo add implements
git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/implements_trivial
cargo run