Parameterized impl Blocks

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:

Get hands-on with 1200+ tech skills courses.