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 {}


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 {}.
  • ...

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

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.