macro_rules! has_impl {
($T:ty, $Trait:path) => { ... };
}Expand description
Check if a concrete type implements a trait at compile time.
Uses the “Inherent Const Fallback” pattern: an inherent const shadows a trait const when the bound is satisfied.
Note: Only works for concrete types. For generic contexts, use
caps_check! with standard traits (Clone, Copy, Debug, Default, Send, Sync).
§Usage
use tola_caps::has_impl;
assert!(has_impl!(String, Clone));
assert!(!has_impl!(String, Copy));
trait MyTrait {}
impl MyTrait for i32 {}
assert!(has_impl!(i32, MyTrait));