We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b75e713 commit cde1c43Copy full SHA for cde1c43
src/generics/trait-bounds.md
@@ -15,3 +15,22 @@ fn main() {
15
let pair = duplicate(foo);
16
}
17
```
18
+
19
+<details>
20
21
+Consider showing a `where` clause syntax. Students can encounter it too when reading code.
22
23
+```rust,ignore
24
+fn duplicate<T>(a: T) -> (T, T)
25
+where
26
+ T: Clone,
27
+{
28
+ (a.clone(), a.clone())
29
+}
30
+```
31
32
+* It declutters the function signature if you have many parameters.
33
+* It has additional features making it more powerful.
34
+ * If someone asks, the extra feature is that the type on the left of ":" can be arbitrary, like `Option<T>`.
35
36
+</details>
0 commit comments