You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/trait-bounds.md
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,40 @@ struct UsesA<'a, T>(A<'a, T>);
95
95
r[bound.trait-object]
96
96
Trait and lifetime bounds are also used to name [trait objects].
97
97
98
+
r[bound.where]
99
+
## Where clauses
100
+
101
+
r[bound.where.intro]
102
+
*Where clauses* provide another way to specify bounds on type and lifetime parameters as well as a way to specify bounds on types that aren't type parameters.
TypeBoundWhereClauseItem -> ForLifetimes? Type `:` TypeParamBounds?
242
-
```
243
-
244
-
r[generics.where.intro]
245
-
*Where clauses* provide another way to specify bounds on type and lifetime parameters as well as a way to specify bounds on types that aren't type parameters.
246
-
247
-
r[generics.where.higher-ranked-lifetimes]
248
-
The `for` keyword can be used to introduce [higher-ranked lifetimes]. It only allows [LifetimeParam] parameters.
249
-
250
-
```rust
251
-
structA<T>
252
-
where
253
-
T:Iterator, // Could use A<T: Iterator> instead
254
-
T::Item:Copy, // Bound on an associated type
255
-
String:PartialEq<T>, // Bound on `String`, using the type parameter
0 commit comments