logo
Expand description

Macro to answer the question: does it implement a trait?

Module :: implements

experimental rust-status docs.rs discord

Macro to answer the question: does it implement a trait?

This solution has a limitation:

  • In case entity is a function and trait is Fn/FnMut/FnOnce which current entity does not implement you will get compile-time error instead of false.

Sample

use implements::*;

dbg!( implements!( 13_i32 => Copy ) );
// < implements!( 13_i32 => Copy ) : true
dbg!( implements!( Box::new( 13_i32 ) => Copy ) );
// < implements!( 13_i32 => Copy ) : false

To add to your project

cargo add implements

Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/implements_trivial
cargo run

Modules

Exposed namespace of the module.

Orphan namespace of the module.

Prelude to use essentials: use my_module::prelude::*.

Own namespace of the module.

Macros

Macro implements to answer the question: does it implement a trait?

Macro instance_of to answer the question: does it implement a trait? Alias of the macro implements.