1 Abstract return types (written `impl Trait` for some trait `Trait`) are only
2 allowed as function and inherent impl return types.
4 Erroneous code example:
8 let count_to_ten: impl Iterator<Item=usize> = 0..10;
9 // error: `impl Trait` not allowed outside of function and inherent method
11 for i in count_to_ten {
17 Make sure `impl Trait` only appears in return-type position.
20 fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
25 for i in count_to_n(10) { // ok!
31 See [RFC 1522] for more details.
33 [RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md