@@ -205,26 +205,46 @@ types cannot be defined in [inherent implementations] nor can they be given a
205205default implementation in traits.
206206
207207An * associated type declaration* declares a signature for associated type
208- definitions. It is written as ` type ` , then an [ identifier] , and
209- finally an optional list of trait bounds.
208+ definitions. It is written in one of the following forms, where ` Assoc ` is the
209+ name of the associated type, ` Params ` is a comma-separated list of type,
210+ lifetime or const parameters, ` Bounds ` is a plus-separated list of trait bounds
211+ on the associated type, and ` WhereBounds ` is a comma-separated list of bounds on
212+ parameters:
213+
214+ ``` rust,ignore
215+ type Assoc;
216+ type Assoc: Bounds;
217+ type Assoc<Params>;
218+ type Assoc<Params>: Bounds;
219+ type Assoc<Params> where WhereBounds;
220+ type Assoc<Params>: Bounds where WhereBounds;
221+ ```
210222
211223The identifier is the name of the declared type alias. The optional trait bounds
212224must be fulfilled by the implementations of the type alias.
213225There is an implicit [ ` Sized ` ] bound on associated types that can be relaxed using the special ` ?Sized ` bound.
214226
215- An * associated type definition* defines a type alias on another type. It is
216- written as ` type ` , then an [ identifier] , then an ` = ` , and finally a [ type] .
227+ An * associated type definition* defines a type alias on for the implementation
228+ of a trait on a type. They are written similarly to an * associated type declaration* ,
229+ but cannot contain ` Bounds ` , but instead must contain a ` Type ` :
230+
231+ ``` rust,ignore
232+ type Assoc = Type;
233+ type Assoc<Params> = Type<Params>;
234+ type Assoc<Params> where WhereBounds = Type;
235+ type Assoc<Params> = Type where WhereBounds;
236+ ```
217237
218238If a type ` Item ` has an associated type ` Assoc ` from a trait ` Trait ` , then
219239` <Item as Trait>::Assoc ` is a type that is an alias of the type specified in the
220240associated type definition. Furthermore, if ` Item ` is a type parameter, then
221241` Item::Assoc ` can be used in type parameters.
222242
223- Associated types may include [ generic parameters] or [ where clauses] ; these may
224- be referred to as generic associated types, or GATs. If the type ` Thing ` has an
225- associated type ` Item ` from a trait ` Trait ` with the generics ` <'a> ` , the type
226- can be named like ` <Thing as Trait>::Item<'x> ` , where ` 'x ` is some lifetime in
227- scope. In this case, ` 'x ` will be used wherever ` 'a ` appears in the associated
243+ Associated types may include [ generic parameters] and [ where clauses] ; these are
244+ often referred to as * generic associated types* , or * GATs* . If the type ` Thing `
245+ has an associated type ` Item ` from a trait ` Trait ` with the generics ` <'a> ` , the
246+ type can be named like ` <Thing as Trait>::Item<'x> ` , where ` 'x ` is some lifetime
247+ in scope. In this case, ` 'x ` will be used wherever ` 'a ` appears in the associated
228248type definitions on impls.
229249
230250``` rust
0 commit comments