rust icon indicating copy to clipboard operation
rust copied to clipboard

Implement new Concept Exercise: turbofish

Open coriolinus opened this issue 5 years ago • 0 comments

This issue describes how to implement the turbofish concept exercise for the rust track.

Goal

Rust offers the ::<_> operator, popularly known as the turbofish. AFAIK no other language has this operator, which is used for offering hints to the type inferencer where it would otherwise fail.

In v2, we have shoehorned some instruction about this operator into the reverse-string exercise, but this comes with a drawback: it implies that people should use the manual operator even when the code is simpler and clearer without it.

Things to teach

  • existence of turbofish operator
  • how to use turbofish operator
  • when using turbofish is required

Things not to teach

  • policy for using turbofish when not required to solve type inference failure
  • partial type hints i.e. collect::<Result<Vec<_>, _>>()

Concepts

  • turbofish

Prequisites

  • generics

Implementing

A sketch of an exercise implementation exists on the playground

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

coriolinus avatar May 19 '20 11:05 coriolinus