Skip to content

Commit 6b9e4ff

Browse files
committed
Add a section on relationship between bounds and wherebounds
1 parent 3c8acda commit 6b9e4ff

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/items/associated-items.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ An *associated type declaration* declares a signature for associated type
208208
definitions. It is written in one of the following forms, where `Assoc` is the
209209
name of the associated type, `Params` is a comma-separated list of type,
210210
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:
211+
that the associated type must meet, and `WhereBounds` is a comma-separated list
212+
of bounds that the parameters must meet:
213213

214214
<!-- ignore: illustrative example forms -->
215215
```rust,ignore
@@ -337,6 +337,19 @@ impl<T> Container for Vec<T> {
337337
}
338338
```
339339

340+
### Relationship between `Bounds` and `WhereBounds`
341+
342+
In this example:
343+
344+
```rust
345+
# use std::fmt::Debug;
346+
trait Example {
347+
type Output<T>: Ord where T: Debug;
348+
}
349+
```
350+
351+
Given a reference to the associated type like `<X as Example>::Output<Y>`, the associated type itself must be `Ord`, and the type `Y` must be `Debug`.
352+
340353
### Required where clauses on generic associated types
341354

342355
Generic associated type declarations on traits currently may require a list of

0 commit comments

Comments
 (0)