1▶`impl Trait` is only allowed as a function return and argument type.
2
3Erroneous code example:
· · ·
4
5```compile_fail,E0562
6▶fn main() {
7 let count_to_ten: impl Iterator<Item=usize> = 0..10;
8 // error: `impl Trait` not allowed outside of function and inherent method
· · ·
8▶ // error: `impl Trait` not allowed outside of function and inherent method
9 // return types
10 for i in count_to_ten {
· · ·
14```
15
16▶Make sure `impl Trait` appears in a function signature.
17
18```
· · ·
21}
22
23▶fn main() {
24 for i in count_to_n(10) { // ok!
25 println!("{}", i);