Crate is_trait

Source
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