19 releases (10 breaking)

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

#2589 in Development tools

Download history 134/week @ 2024-08-17 189/week @ 2024-08-24 176/week @ 2024-08-31 138/week @ 2024-09-07 383/week @ 2024-09-14 309/week @ 2024-09-21 186/week @ 2024-09-28 82/week @ 2024-10-05 219/week @ 2024-10-12 170/week @ 2024-10-19 330/week @ 2024-10-26 197/week @ 2024-11-02 42/week @ 2024-11-09 100/week @ 2024-11-16 142/week @ 2024-11-23 109/week @ 2024-11-30

413 downloads per month
Used in 77 crates (2 directly)

MIT license

9KB
99 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

Features