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
This adds a section with rules describing associated item constraints.
I'm not 100% certain this is the best chapter layout to place this
section. Perhaps it should go somewhere else?
I have intentionally used the terminology "associated item constraint"
even though it is currently only *types* that are constrained. My
intention is that once MCGA is stabilized, it will also include consts.
An *associated item constraint* constrains an [associated type] of a trait. There are two kinds of associated item constraints: equality constraints and bound constraints.
235
+
236
+
r[generics.associated.equality]
237
+
An *equality constraint* fixes the associated item to a specific type. It is specified with the [GenericArgsBinding] syntax.
238
+
239
+
> [!EXAMPLE]
240
+
> ```rust
241
+
> // The `Item` associated item is specified to be `i32`.
A *bound constraint* requires the associated item to satisfy a [trait bound] without fixing it to a concrete type. It is specified with the [GenericArgsBounds] syntax.
249
+
250
+
> [!EXAMPLE]
251
+
> ```rust
252
+
> # use std::fmt::Display;
253
+
> #
254
+
> // The `Item` associated type is required to implement Display.
0 commit comments