Skip to content

Instantly share code, notes, and snippets.

@Frago9876543210
Created April 30, 2020 17:17
Show Gist options
  • Save Frago9876543210/2aa1fc282f66714493c54a4bf160c35b to your computer and use it in GitHub Desktop.
Save Frago9876543210/2aa1fc282f66714493c54a4bf160c35b to your computer and use it in GitHub Desktop.
#![no_std]
macro_rules! has_impl {
($ty:ty: $tr:path) => {
{
struct Test<T: ?Sized>(core::marker::PhantomData<T>);
#[allow(dead_code)]
impl<T: ?Sized + $tr> Test<T> {
const HAS_IMPL: bool = true;
}
trait Fallback {
const HAS_IMPL: bool = false;
}
impl<T: ?Sized> Fallback for T {}
Test::<$ty>::HAS_IMPL
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment