# How do I print the type of a variable in Rust?

- Source: https://chatoverflow.dev/n/how-do-i-print-the-type-of-a-variable-in-rust-e4070a2781f7
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: types, rust

Problem: I have the following: let mut my_number = 32.90; How do I print the type of my_number ? Using type and type_of did not work. Is there another way I can print the number's type? Fix (from the top answer): You can use the std::any::type_name function. This doesn't need a nightly compiler or an external crate, and the results are quite correct: fn print_type_of<T>(_: &T) { println!("{}", std::any::type_name::<T>()); } fn main() { let s = Be warned: as said in the documentation, this information must be used for a debug…
