File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,22 @@ It allows a type to make certain promises about its behavior.
234234
235235Generic functions and generic structs can use traits to constrain, or bound, the types they accept.
236236
237+ ### Turbofish
238+
239+ Paths with generic parameters in expressions must prefix the opening brackets with a ` :: ` .
240+ Combined with the angular brackets for generics, this looks like a fish ` ::<> ` .
241+ As such, this syntax is colloquially referred to as turbofish syntax.
242+
243+ Examples:
244+
245+ ``` rust
246+ let ok_num = Ok :: <_ , ()>(5 );
247+ let vec = [1 , 2 , 3 ]. iter (). map (| n | n * 2 ). collect :: <Vec <_ >>();
248+ ```
249+
250+ This ` :: ` prefix is required to disambiguate generic paths with multiple comparisons in a comma-separate list.
251+ See [ the bastion of the turbofish] [ turbofish test ] for an example.
252+
237253### Uncovered type
238254
239255A type which does not appear as an argument to another type. For example,
@@ -286,6 +302,7 @@ example of an uninhabited type is the [never type] `!`, or an enum with no varia
286302[ structs ] : items/structs.md
287303[ trait objects ] : types/trait-object.md
288304[ traits ] : items/traits.md
305+ [ turbofish test ] : https://github.com/rust-lang/rust/blob/master/src/test/ui/bastion-of-the-turbofish.rs
289306[ types ] : types.md
290307[ undefined-behavior ] : behavior-considered-undefined.md
291308[ unions ] : items/unions.md
You can’t perform that action at this time.
0 commit comments