Expose type_name() method on Any. · Issue #68379 · rust-lang/rust (original) (raw)

In a similar spirit to #61533, it would be nice if the Any trait contained an auto implemented method akin to:

fn type_name(&self) -> &'static str { std::any::type_name::() }

This way it would be a lot easier print and surface errors like accidentally trying to cast Box<T> to T because &Box<T> is also &Any.