Skip to content

Commit 1812f47

Browse files
committed
Split argument/return impl-trait
1 parent 8ee5e63 commit 1812f47

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/types.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,18 +654,32 @@ fn to_vec<A: Clone>(xs: &[A]) -> Vec<A> {
654654
Here, `first` has type `A`, referring to `to_vec`'s `A` type parameter; and
655655
`rest` has type `Vec<A>`, a vector with element type `A`.
656656

657-
## Abstract types
657+
## Anonymous type parameters
658658

659659
> Note: This section is a placeholder for more comprehensive reference
660660
> material.
661661
662-
Abstract types are types that stand in for another concrete type where the
662+
> Note: This is often called "impl Trait in argument position".
663+
664+
Functions can declare an argument to be an anonymous type parameter where the
665+
callee must provide a type that has the bounds declared by the anonymous type
666+
parameter and the function can only use the methods available by the trait
667+
bounds of the anonymous type parameter.
668+
669+
They are written as `impl` followed by a set of trait bounds.
670+
671+
## Abstract return types
672+
673+
> Note: This section is a placeholder for more comprehensive reference
674+
> material.
675+
676+
> Note: This is often called "impl Trait in return position".
677+
678+
Functions, except for associated trait functions, can return an abstract
679+
return type. These types stand in for another concrete type where the
663680
use-site may only use the trait methods declared by the trait bounds of the
664681
type.
665682

666-
Abstract types are only allowed as the type of a parameter or return type of a
667-
function except for associated functions on traits.
668-
669683
They are written as `impl` followed by a set of trait bounds.
670684

671685
## Self types

0 commit comments

Comments
 (0)