implements

Crates.ioimplements
lib.rsimplements
version0.8.0
sourcesrc
created_at2021-11-29 07:05:56.723889
updated_at2024-05-11 22:35:49.282962
descriptionMacro to answer the question: does it implement a trait?
homepagehttps://github.com/Wandalen/wTools/tree/master/module/core/implements
repositoryhttps://github.com/Wandalen/wTools/tree/master/module/core/implements
max_upload_size
id489116
size35,805
Wandalen (Wandalen)

documentation

https://docs.rs/implements

README

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
Commit count: 0

cargo fmt