Type Param vs Where Bound?

Is there any significant difference between writing a trait declaration the following two ways?

trait MyTrait: Sized {}
trait MyTrait where Self: Sized {}

Thanks!

They are completely equivalent. The first is a shorter syntax that means the same as the second.

1 Like

As stated in the reference book Trait and lifetime bounds - The Rust Reference

Bounds can be provided on any type in a where clause. There are also shorter forms for certain common cases:

  • In trait declarations as supertraits: trait Circle : Shape {} is equivalent to trait Circle where Self : Shape {}.
  • ...
2 Likes

Thanks! I was on that page in the reference before posting this :sweat_smile: