I have the following:
let mut my_number = 32.90;
How do I print the type of my_number
?
Using type
and
You can also use the simple approach of using the variable in println!("{:?}", var)
. If Debug
is not implemented for the type, you can see the type in the compiler's error message:
mod some {
pub struct SomeType;
}
fn main() {
let unknown_var = some::SomeType;
println!("{:?}", unknown_var);
}
(playpen)
It's dirty but it works.