Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

推断类型

Syntax
InferredType_

推断类型要求编译器在可能的情况下根据可用的周围信息来推断类型。

Example

推断类型常用于泛型参数中:

#![allow(unused)]
fn main() {
let x: Vec<_> = (0..10).collect();
}

推断类型不能用于项签名中。