Skip to content

Commit 2d8d50b

Browse files
Adjust for RPITIT and AFIT
1 parent 5262e1c commit 2d8d50b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/items/traits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait Example {
4343
}
4444
```
4545

46-
Trait functions are not allowed to be [`async`] or [`const`].
46+
Trait functions are not allowed to be [`const`].
4747

4848
## Trait bounds
4949

src/types/impl-trait.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ which also avoids the drawbacks of using a boxed trait object.
8888
Similarly, the concrete types of iterators could become very complex, incorporating the types of all previous iterators in a chain.
8989
Returning `impl Iterator` means that a function only exposes the `Iterator` trait as a bound on its return type, instead of explicitly specifying all of the other iterator types involved.
9090

91+
## Return-position `impl Trait` in traits and trait implementations
92+
93+
Functions in traits may also use `impl Trait` as a syntax for an anonymous associated type.
94+
95+
Every `impl Trait` in the return type of an associated function in a trait is desugared to an anonymous associated type. The return type that appears in the implementation's function signature is used to determine the value of the associated type.
96+
9197
### Differences between generics and `impl Trait` in return position
9298

9399
In argument position, `impl Trait` is very similar in semantics to a generic type parameter.
@@ -121,8 +127,8 @@ Instead, the function chooses the return type, but only promises that it will im
121127

122128
## Limitations
123129

124-
`impl Trait` can only appear as a parameter or return type of a free or inherent function.
125-
It cannot appear inside implementations of traits, nor can it be the type of a let binding or appear inside a type alias.
130+
`impl Trait` can only appear as a parameter or return type of a non-`extern` function.
131+
It cannot be the type of a `let` binding, field type, or appear inside a type alias.
126132

127133
[closures]: closure.md
128134
[_GenericArgs_]: ../paths.md#paths-in-expressions

0 commit comments

Comments
 (0)