Closed
Description
My attempt to call Any::get_type_id()
and use its return value of as an instance of fmt::Debug
does not work without import of std::any::TypeId
struct: http://doc.rust-lang.org/std/any/struct.TypeId.html
Example code:
use std::thread;
// use std::any::TypeId; // uncomment this line to make the compile work
fn main() {
let b1 = Box::new(3u64);
println!("hello world, b1: {:?}", b1);
let child = thread::Thread::scoped(|| {
let b2 = Box::new(4u64);
println!("other thread b2: {:?}", b2);
});
match child.join() {
Ok(()) => {}
Err(ref panic_arg) => {
if let Some(s) = panic_arg.downcast_ref::<&str>() {
println!("whoops child died with str: {}", s);
} else if let Some(s) = panic_arg.downcast_ref::<String>() {
println!("whoops child died with String: {}", s);
} else {
let id = panic_arg.get_type_id();
println!("whoops child died with unknown panic arg, id: {:?}", id);
}
}
}
}
Transcript of attempt to compile:
<anon>:19:26: 19:49 error: source trait is private
<anon>:19 let id = panic_arg.get_type_id();
^~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101