0

Whats the difference between

my_func<T: MyTrait>(...) {...}

and

my_func<T>(...) where T: MyTrait {...}

?

K. Biermann
  • 1,295
  • 10
  • 22

1 Answers1

3

One is written with an explicit where clause, the other isn't.

Okay, okay; if you want to be picky, the differences are:

  • You can't introduce a generic parameter with a where clause.
  • You can't constrain anything other than generic parameters in the generic argument list.

But in terms of what changes when you move constraints from the generic argument list to a where clause, they're the same.

DK.
  • 55,277
  • 5
  • 189
  • 162