Expand description
This crate adds a is_trait!
macro for getting a runtime value for if a type implements a trait
This can be useful for test, where you can have a test fail instead of getting a compile error
Example:
ⓘ
use is_trait::is_trait;
struct Thing;
struct OtherThing;
trait SomeTrait {}
impl SomeTrait for Thing {}
assert!(is_trait!(Thing, SomeTrait));
assert!(is_trait!(OtherThing, SomeTrait)); // FAILS
Macros§
- const_
is_ trait - Like
is_trait
but uses const trait impls - is_
trait - See crate level docs for usage