impl和dyn用法
摘要:先推荐一个链接 理解 Rust 2018 edition 的两个新关键字 —— impl 和 dyn 官方文档中,impl是限定泛型的语法糖,所以 trait Trait {} fn foo<T: Trait>(arg: T) { } fn foo(arg: impl Trait) { } 这2种情
阅读全文
posted @
2020-04-15 10:10
chen8840
阅读(1311)
推荐(0)
rust中的ref
摘要:理解Rust的引用与借用(好文链接) #![feature(core_intrinsics)] fn print_type_of<T>(_: T) { println!("{}", unsafe { std::intrinsics::type_name::<T>() }); } fn main()
阅读全文
posted @
2020-04-14 17:09
chen8840
阅读(1893)
推荐(0)
如何在Rust中打印变量的类型?
摘要:#![feature(core_intrinsics)] fn print_type_of<T>(_: T) { println!("{}", unsafe { std::intrinsics::type_name::<T>() }); } fn main() { print_type_of(32.
阅读全文
posted @
2020-04-14 15:54
chen8840
阅读(1879)
推荐(0)