Rust中where子句中特征的可能运算符是什么? [英] What are the possible operators for traits in a where clause in Rust?
问题描述
我正在学习Rust,并进入了关于特征界限的章节.在该章中,他们使用+
(加号)运算符给出了一个示例,以列举where
子句中所有必需的特征.
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 a where
clause.
Rust中的特征还可以使用哪些其他运算符?我进行了搜索,但找不到任何与此相关的文档. Rust是否支持或"符号,方括号,否定符号?
What other operators are allowed on traits in Rust? I searched but I wasn't able to find any documentation about this. Does Rust support 'or' notation, brackets, negation?
推荐答案
或"符号
不.这样的事情对我来说毫无意义-如果可能是A
或B
,那么代码将如何处理?
No. Such a thing doesn't make sense to me — what would the code do if something could be A
OR B
?
括号
否,除非您在Fn(...)
和朋友中加上括号,否则不要将尖括号用作泛型(Vec<T>
)或将方括号用作切片([u8]
),但这是类型的一部分.
No, unless you count the parenthesis in Fn(...)
and friends, the use of angle brackets as generics (Vec<T>
) 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?
否定
不.我认为这是由于处理否定逻辑会使事情变得更加复杂.
No. I believe this is due to the fact that handling negative logic makes things a lot more complicated.
其他运算符
other operators
来源:我已经编写了 Rust代码解析器.虽然可能我错过了一些东西,但它可以解析我抛出的所有〜37500 Rust文件,因此非常合适.
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.
这篇关于Rust中where子句中特征的可能运算符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!