Parameterized impl Blocks
We'll cover the following...
Using greet
as a function is a bit clunky. It would feel more natural to define it as a method. However, in order to make that work, we’ll need to put type parameters on an impl
block. In my opinion at least, this example of type parameters looks a little unusual, because it uses two sets of angle brackets. But the logic makes perfect sense once explained. First, let’s look at the working code, and then we’ll explain how it works:
Access this course and 1400+ top-rated courses and projects.