这种 struct 被称为turbofish.如果你搜索这个语句,你会发现它的定义和用法.
虽然The Rust Programming Language的第一版已经过时,但我觉得this particular section比second book好.
引用第二版:
path::<...>
method::<...>
您可以在编译器无法推断类型参数的任何情况下使用它,例如.
fn main () {
let a = (0..255).sum();
let b = (0..255).sum::<u32>();
let c: u32 = (0..255).sum();
}
a
does not work because it cannot deduce the variable type.
b
does work because we specify the type parameter directly with the turbofish syntax.
c
does work because we specify the type of c
directly.