Skip to content

Commit af6a54d

Browse files
committed
Move intro to the top
1 parent 5ff13ac commit af6a54d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/trait-bounds.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
r[bound]
22
# Trait and lifetime bounds
33

4+
r[bound.intro]
5+
[Trait] and lifetime bounds provide a way for [generic items][generic] to restrict which types and lifetimes are used as their parameters. Bounds can be provided on any type in a [where clause]. There are also shorter forms for certain common cases:
6+
7+
* Bounds written after declaring a [generic parameter][generic]: `fn f<A: Copy>() {}` is the same as `fn f<A>() where A: Copy {}`.
8+
* In trait declarations as [supertraits]: `trait Circle : Shape {}` is equivalent to `trait Circle where Self : Shape {}`.
9+
* In trait declarations as bounds on [associated types]: `trait A { type B: Copy; }` is equivalent to `trait A where Self::B: Copy { type B; }`.
10+
411
r[bound.syntax]
512
```grammar,miscellaneous
613
TypeParamBounds -> TypeParamBound ( `+` TypeParamBound )* `+`?
@@ -30,13 +37,6 @@ UseBoundGenericArg ->
3037
| `Self`
3138
```
3239

33-
r[bound.intro]
34-
[Trait] and lifetime bounds provide a way for [generic items][generic] to restrict which types and lifetimes are used as their parameters. Bounds can be provided on any type in a [where clause]. There are also shorter forms for certain common cases:
35-
36-
* Bounds written after declaring a [generic parameter][generic]: `fn f<A: Copy>() {}` is the same as `fn f<A>() where A: Copy {}`.
37-
* In trait declarations as [supertraits]: `trait Circle : Shape {}` is equivalent to `trait Circle where Self : Shape {}`.
38-
* In trait declarations as bounds on [associated types]: `trait A { type B: Copy; }` is equivalent to `trait A where Self::B: Copy { type B; }`.
39-
4040
r[bound.satisfaction]
4141
Bounds on an item must be satisfied when using the item. When type checking and borrow checking a generic item, the bounds can be used to determine that a trait is implemented for a type. For example, given `Ty: Trait`
4242

0 commit comments

Comments
 (0)