标签:toolchain span lis name too div safe 打印 pre
#![feature(core_intrinsics)]
fn print_type_of<T>(_: T) {
println!("{}", unsafe { std::intrinsics::type_name::<T>() });
}
fn main() {
print_type_of(32.90); // prints "f64"
print_type_of(vec![1, 2, 4]); // prints "std::vec::Vec<i32>"
print_type_of("foo"); // prints "&str"
}
需要切换rustup到nightly版本才能运行cargo run
查看rustup版本
rustup toolchain list
切换到nightly版本
rustup default nightly
标签:toolchain span lis name too div safe 打印 pre
原文地址:https://www.cnblogs.com/chen8840/p/12698527.html