macro_rules! of_type {
(Self) => { ... };
($ty:ident) => { ... };
($ty:ty) => { ... };
}Expand description
Get the name of the given type as a &'static str.
This macro resolves Self to the appropriate type when used inside an impl block.
If the given type is a single identifier and is not Self, the macro expands to a
string literal at compile time. For more complex types, the macro uses runtime type
name retrieval with caching.
ยงExamples
struct MyStruct;
struct MyGenericStruct<T>(std::marker::PhantomData<T>);
assert_eq!(pretty_name::of_type!(MyStruct), "MyStruct");
assert_eq!(pretty_name::of_type!(MyGenericStruct<u32>), "MyGenericStruct<u32>");