Skip to content

Commit

Permalink
Adjust for RPITIT and AFIT
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 26, 2023
1 parent 5262e1c commit d82c9ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/items/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait Example {
}
```

Trait functions are not allowed to be [`async`] or [`const`].
Trait functions are not allowed to be [`const`].

## Trait bounds

Expand Down
10 changes: 8 additions & 2 deletions src/types/impl-trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ which also avoids the drawbacks of using a boxed trait object.
Similarly, the concrete types of iterators could become very complex, incorporating the types of all previous iterators in a chain.
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.

## Return-position `impl Trait` in traits and trait implementations

Functions in traits may also use `impl Trait` as a syntax for an anonymous associated type.

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.

### Differences between generics and `impl Trait` in return position

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

## Limitations

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

[closures]: closure.md
[_GenericArgs_]: ../paths.md#paths-in-expressions
Expand Down

0 comments on commit d82c9ac

Please sign in to comment.