Rust Type Of

[Solved] Rust Type Of | Rust - Code Explorer | yomemimo.com
Question : rust type of

Answered by : taminoturoko-briggs

fn print_type_of<T>(_: &T) { println!("{}", std::any::type_name::<T>())
}
fn main() { let s = "Hello"; let i = 42; print_type_of(&s); // &str print_type_of(&i); // i32 print_type_of(&main); // playground::main print_type_of(&print_type_of::<i32>); // playground::print_type_of<i32> print_type_of(&{ || "Hi!" }); // playground::main::{{closure}}
}

Source : https://stackoverflow.com/questions/21747136/how-do-i-print-the-type-of-a-variable | Last Update : Sat, 28 May 22

Answers related to rust type of

Code Explorer Popular Question For Rust