"Plus" sign in trait and type definitions

Sometimes I see code written like

pub trait name: Clone + Eq + Ord + Hash + Serialize + Debug {...}


pub trait abc {
    type one: TwoType + ThreeType;

can someone explain what this mean, or give the appropriate chapter in the reference manual. I might have overlooked it. Also after I know what this is I might change the topic headline.

1 Like

These are not types, but trait bounds. The plus sign allows you to combine multiple requirements in a trait bound. type OneType: TwoTrait + ThreeTrait means that the OneType associated type must implement both TwoTrait and ThreeTrait traits.

The Trait bounds section in the book explains this feature.


Ah, I see. Thanks.

The Trait bounds section has moved, in case you run into link-rot issues with the above.