What are the possible operators for traits in a where clause in Rust?

前端 未结 1 1211
傲寒
傲寒 2020-12-21 12:45

I\'m learning Rust and got to the chapter on trait bounds. In that chapter, they give an example with the + (plus) operator to enumerate all required traits in

1条回答
  •  囚心锁ツ
    2020-12-21 13:18

    'or' notation

    No. Such a thing doesn't make sense to me — what would the code do if something could be A OR B?

    brackets

    No, unless you count the parenthesis in Fn(...) and friends, the use of angle brackets as generics (Vec) or the use of square brackets in slices ([u8]), but these are parts of types.

    Again, such a request doesn't make sense to me, why would you need any kind of grouping?

    negation

    No. I believe this is due to the fact that handling negative logic makes things a lot more complicated.

    other operators

    There's the ? (question mark) bound.


    Source: I've written a parser of Rust code. While it's possible I've missed something, it parses all the ~37500 Rust files I've thrown at it, so it's a pretty good fit.

    0 讨论(0)
提交回复
热议问题