还输 > 函数

This commit is contained in:
863056768
2022-03-06 10:21:49 +08:00
committed by GitHub
parent 2a8e014329
commit 5ed1a56076

View File

@ -40,7 +40,7 @@ fn main() {
assert_eq!("u32".to_string(), type_of(&x));
}
// 以下还输可以获取传入参数的类型,并返回类型的字符串形式,例如 "i8", "u8", "i32", "u32"
// 以下函数可以获取传入参数的类型,并返回类型的字符串形式,例如 "i8", "u8", "i32", "u32"
fn type_of<T>(_: &T) -> String {
format!("{}", std::any::type_name::<T>())
}
@ -142,6 +142,7 @@ fn main() {
// 整数减法
assert!(1i32 - 2 == __);
assert!(1u8 - 2 == -1);
assert!(3 * 50 == __);
assert!(9.6 / 3.2 == 3.0); // error ! 修改它让代码工作