Created
April 30, 2020 17:17
-
-
Save Frago9876543210/2aa1fc282f66714493c54a4bf160c35b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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