]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0121.md
6c20b2803cbe361b643576c44a6e9a0c0b37ba6e
[rust.git] / src / librustc_error_codes / error_codes / E0121.md
1 The type placeholder `_` was used withing a type on an item's signature.
2
3 Erroneous code example:
4
5 ```compile_fail,E0121
6 fn foo() -> _ { 5 } // error
7
8 static BAR: _ = "test"; // error
9 ```
10
11 In those cases, you need to provide the type explicitly:
12
13 ```
14 fn foo() -> i32 { 5 } // ok!
15
16 static BAR: &str = "test"; // ok!
17 ```
18
19 The type placeholder `_` can be used outside item's signature as follows:
20
21 ```
22 let x = "a4a".split('4')
23     .collect::<Vec<_>>(); // No need to precise the Vec's generic type.
24 ```