Skip to navigation
How check type of variable
25.12.22
use std::any::type_name; fn type_of
(_: T) -> &'static str { type_name::
() } fn main() { let x = 21; let y = 2.5; println!("{}", type_of(&y)); println!("{}", type_of(x)); } let x = 21; let y = 2.5; type_of(x) //i32
https://users.rust-lang.org/t/how-check-type-of-variable/33845/2
Reply
Anonymous
Information Epoch 1732460813
Design for visibility.
Home
Notebook
Contact us