use cluConstData::const_data;
use std::marker::PhantomData;
pub trait TypeTrait {
const TYPE: &'static str;
#[inline]
fn as_type_str() -> &'static str {
Self::TYPE
}
}
impl TypeTrait for usize {
const TYPE: &'static str = "usize";
}
impl TypeTrait for (usize, usize) {
const_data! {
const TYPE: &'static str = usize::TYPE, " + ", usize::TYPE;
}
}
impl TypeTrait for (PhantomData<()>, usize) {
const_data! {
const TYPE: &'static str = "PhantomData<()>", " + ", usize::TYPE;
}
}
fn main() {
println!("#1 {:?}", usize::as_type_str());
assert_eq!(usize::as_type_str(), "usize");
println!("#2 {:?}", <(usize, usize)>::as_type_str());
assert_eq!(<(usize, usize)>::as_type_str(), "usize + usize");
}