Returns the name of a type as a string slice.
This is intended for diagnostic use. The exact contents and format of the
string returned are not specified, other than being a best-effort
description of the type. For example, amongst the strings
type_name::<Option<String>>() might return are
The returned string must not be considered to be a unique identifier of a type as multiple types may map to the same type name. Similarly, there is no guarantee that all parts of a type will appear in the returned string: for example, lifetime specifiers are currently not included. In addition, the output may change between versions of the compiler.
The current implementation uses the same infrastructure as compiler diagnostics and debuginfo, but this is not guaranteed.
assert_eq!( std::any::type_name::<Option<String>>(), "core::option::Option<alloc::string::String>", );