Rust中where子句中traits的可能运算符是什么?

时间:2017-10-16 21:22:19

标签: rust traits method-signature type-signature

我正在学习Rust,并进入了关于特质界限的章节。在该章中,他们给出了const datastore = require('@google-cloud/datastore'); exports.helloWorld = function helloWorld(req, res) { const client = datastore(); const key = client.key(['Person', 'harry']); client.get(key, function(err, entity) { res.status(200).send(JSON.stringify(entity)); }); }; (加号)运算符的示例,以枚举+子句中所有必需的特征。

Rust允许其他哪些操作员使用特征?我搜索过,但我找不到任何关于此的文档。 Rust支持'或'符号,括号,否定?

1 个答案:

答案 0 :(得分:4)

  

'或'符号

没有。这样的事情对我来说没有意义 - 如果事情可能是AB,代码会做什么?

  

括号

不,除非你计算Fn(...)和朋友中的括号,使用尖括号作为泛型(Vec<T>)或在切片中使用方括号([u8]),但这些是类型的一部分。

同样,这样的请求对我没有意义,为什么你需要任何类型的分组?

  

否定

没有。我相信这是因为处理负逻辑会使事情变得复杂得多。

  

其他运营商

There's the ? (question mark) bound

来源:我写过a parser of Rust code。尽管我可能错过了一些东西,但它解析了所有我扔过的~37500个Rust文件,所以它非常适合。