Skip to content

Commit 94085bb

Browse files
committed
use "argument", "parameter" more consistently
Be more consistent about using "argument" to mean a concrete value provided by a function caller, and "parameter" to mean the abstract input to the function. Retain a few instances of the phrasing "in argument position", because it appears in the RFCs and implementation. Also make a note about the historical terminology inconsistency.
1 parent 1a2f82e commit 94085bb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/types/impl-trait.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ fn bar() -> impl Trait {
2424
## Anonymous type parameters
2525

2626
> Note: This is often called "impl Trait in argument position".
27+
(The term "parameter" is more correct here, but "impl Trait in argument position" is the phrasing used during the development of this feature, and it remains in parts of the implementation.)
2728

28-
Functions can use `impl` followed by a set of trait bounds to declare an argument as having an anonymous type.
29+
Functions can use `impl` followed by a set of trait bounds to declare a parameter as having an anonymous type.
2930
The caller must provide a type that satisfies the bounds declared by the anonymous type parameter, and the function can only use the methods available through the trait bounds of the anonymous type parameter.
3031

3132
For example, these two forms are almost equivalent:
@@ -45,9 +46,9 @@ fn foo(arg: impl Trait) {
4546
That is, `impl Trait` in argument position is syntactic sugar for a generic type parameter like `<T: Trait>`, except that the type is anonymous and doesn't appear in the [_GenericParams_] list.
4647

4748
> **Note:**
48-
> For function arguments, generic type parameters and `impl Trait` are not exactly equivalent.
49+
> For function parameters, generic type parameters and `impl Trait` are not exactly equivalent.
4950
> With a generic parameter such as `<T: Trait>`, the caller has the option to explicitly specify the generic argument for `T` at the call site using [_GenericArgs_], for example, `foo::<usize>(1)`.
50-
> If `impl Trait` is the type of *any* function argument, then the caller can't ever provide any generic arguments when calling that function.
51+
> If `impl Trait` is the type of *any* function parameter, then the caller can't ever provide any generic arguments when calling that function.
5152
This includes generic arguments for the return type or any const generics.
5253
>
5354
> Therefore, changing the function signature from either one to the other can constitute a breaking change for the callers of a function.
@@ -112,7 +113,7 @@ Instead, the function chooses the return type, but only promises that it will im
112113

113114
## Limitations
114115

115-
`impl Trait` can only appear as the argument or return type of a free or inherent function.
116+
`impl Trait` can only appear as a parameter or return type of a free or inherent function.
116117
It cannot appear inside implementations of traits, nor can it be the type of a let binding or appear inside a type alias.
117118

118119
[closures]: closure.md

0 commit comments

Comments
 (0)