File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -944,9 +944,20 @@ fn foo<T>(x: T) where T: Debug {
944
944
```
945
945
946
946
When a generic function is referenced, its type is instantiated based on the
947
- context of the reference. For example, calling the ` iter ` function defined
948
- above on ` [1, 2] ` will instantiate type parameter ` T ` with ` i32 ` , and require
949
- the closure parameter to have type ` Fn(i32) ` .
947
+ context of the reference. For example, calling the ` foo ` function here:
948
+
949
+ ```
950
+ use std::fmt::Debug;
951
+
952
+ fn foo<T>(x: &[T]) where T: Debug {
953
+ // details elided
954
+ # ()
955
+ }
956
+
957
+ foo(&[1, 2]);
958
+ ```
959
+
960
+ will instantiate type parameter ` T ` with ` i32 ` .
950
961
951
962
The type parameters can also be explicitly supplied in a trailing
952
963
[ path] ( #paths ) component after the function name. This might be necessary if
You can’t perform that action at this time.
0 commit comments