Closed
Description
The Debug
impl of Any
is currently very simple, it always returns "Any"
:
use std::any::Any;
/// I don't care if this downcasts to a string,
/// it's all "Any" to me.
fn print_any(something: &Any) {
println!("{:?}", something);
}
fn main() {
print_any(&String::from("Hello"));
}
This shows up in panic messages when e.g. unwrap()
is called on a thread::Result
of a panicked thread. The implementation could do what the default panic hook already does and try to downcast the reference to &'static str
and String
(and maybe also Cow<'static, str>
, though that might be very unusual) and, if successful, include the contents into the output or simply delegate to the string's Debug
.