How to know the data type in rust

How to Determine the Data Type in Rust

In Rust, you can determine the data type of a variable or expression using the std::mem::type_name function. This function returns a string representation of the type. Here's an example:

fn main() {
    let number = 42;
    let type_name = std::any::type_name::<typeof(number)>();
    println!("The type of 'number' is: {}", type_name);
}

This will output: The type of 'number' is: i32.

You can replace number with any variable or expression you want to check the type of. Keep in mind that this method requires the std::any::type_name function from the std module.