Description
Currently TypeId
s have uninformative derived Debug
impls:
fn main() {
println!("{:?}", std::any::TypeId::of::<usize>());
}
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.91s
Running `target/debug/playground`
TypeId { t: 8766594652559642870 }
This results in fairly poor Debug output for dynamic types like anymap
.
I think it could be quite nice for debugging/logging/etc to allow printing the type name from a TypeId
in the Debug impl. It would provide an out of the box improvement to debugging existing dynamic typing tools, and IIUC the contents of Debug impls in the standard library are not considered stable so there's neither a breaking change here nor a de facto stabilization of the type_name representation.
I assume this would need to rely on some unstable intrinsic being exposed to get the type_name of an ID at run time, but I'm not really aware what would be needed.
Thoughts? cc @oli-obk as we had discussed this a bit on IRC.