17 releases (8 breaking)

0.8.0 May 11, 2024
0.7.0 Mar 16, 2024
0.6.0 Mar 16, 2024
0.3.0 Oct 28, 2023
0.0.6 Nov 29, 2021

#2391 in Development tools

Download history 160/week @ 2024-04-04 173/week @ 2024-04-11 188/week @ 2024-04-18 166/week @ 2024-04-25 173/week @ 2024-05-02 429/week @ 2024-05-09 227/week @ 2024-05-16 250/week @ 2024-05-23 395/week @ 2024-05-30 261/week @ 2024-06-06 221/week @ 2024-06-13 321/week @ 2024-06-20 206/week @ 2024-06-27 56/week @ 2024-07-04 190/week @ 2024-07-11 214/week @ 2024-07-18

730 downloads per month
Used in 92 crates (2 directly)

MIT license

11KB
95 lines

Module :: implements

experimental rust-status docs.rs Open in Gitpod 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.

Basic use-case

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
cargo run --example implements_trivial

No runtime deps