-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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
.
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.