Any is a Rust standard-library trait used to inspect a value’s type at runtime and try to recover a specific type. In a panic hook, the panic payload is held as dyn Any + Send. A hook can call downcast_ref::<&str>() to ask, “Is this payload a borrowed string?” If it is, the call returns a reference to that string; otherwise, it returns None. section 21.2
fn main() {
std::panic::set_hook(Box::new(|info| {
if let Some(payload) = info.payload().downcast_ref::<&str>() {
println!("{payload}");
} else {
println!("No payload!");
}
}));
panic!("Oh no");
}
The hook prints the payload when downcast_ref::<&str>() succeeds and prints “No payload!” otherwise. This demonstrates a type check, not a guarantee that every panic has a string payload. section 21.2
Watch the capitalization: Any is a trait; iterator .any() is a different API that checks whether any item meets a condition. section 21.2 section 9.1.3

