diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-06-18 13:38:09 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-06-18 13:38:09 +0530 |
| commit | 39e4d03e35ddc65f69c04f58061403986323ed50 (patch) | |
| tree | f5acd6d32aca8a6c46f3835332c7a7409a39a297 /src/doc/reference.md | |
| parent | b780bc513c416840ef7da3580b50248e4af07659 (diff) | |
| parent | 5a63326442fe068c63dcd7cdd60ca6be25ce666a (diff) | |
| download | rust-39e4d03e35ddc65f69c04f58061403986323ed50.tar.gz rust-39e4d03e35ddc65f69c04f58061403986323ed50.zip | |
Rollup merge of #26342 - steveklabnik:quix_reference_fix, r=alexcrichton
https://github.com/rust-lang/rust/pull/26323/files#r32503568
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 5be61a51bf0..8b7b3b9b15c 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -944,9 +944,20 @@ fn foo<T>(x: T) where T: Debug { ``` When a generic function is referenced, its type is instantiated based on the -context of the reference. For example, calling the `iter` function defined -above on `[1, 2]` will instantiate type parameter `T` with `i32`, and require -the closure parameter to have type `Fn(i32)`. +context of the reference. For example, calling the `foo` function here: + +``` +use std::fmt::Debug; + +fn foo<T>(x: &[T]) where T: Debug { + // details elided + # () +} + +foo(&[1, 2]); +``` + +will instantiate type parameter `T` with `i32`. The type parameters can also be explicitly supplied in a trailing [path](#paths) component after the function name. This might be necessary if |
