What's the difference between `f(x: impl Trait)` and `f<T: Trait>(x: T)`?

Is the former just a sugar?

Yes, mostly. There are a few superficial differences, like impl Trait can't be explicitly specified in the turbofish.

Do note, however, that return-position impl Trait is very different from generics.

3 Likes

The only difference is that with the latter you can call the function specifying the concrete type for T, for example f::<u32>(0)

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.