#impl #compile #compile-time #at #time #has

has_impl

Check if trait is implemented for type in compile time

1 unstable release

0.1.0 Jun 4, 2020

#7 in #at

MIT license

3KB

has_impl

Build Status Latest Version Documentation

Check if trait is implemented for type at compile time

Example

use has_impl::*;

trait Foo {}

impl Foo for i32 {}

fn main() {
	assert_eq!(has_impl!(i32: Foo), true);
}

Installing

[dependencies]
has_impl = "0.1"

lib.rs:

This crate provides has_impl!(type: Trait) macro to check if Trait is implemented for type at complie time

use has_impl::*;

trait Foo {}

impl Foo for i32 {}

fn main() {
assert_eq!(has_impl!(i32: Foo), true);
}

No runtime deps