Why does Rust need the `if let` syntax?

前端 未结 4 1353
渐次进展
渐次进展 2020-12-18 21:39

Coming from other functional languages (and being a Rust newbie), I\'m a bit surprised by the motivation of Rust\'s if let syntax. The RFC mentions that without

4条回答
  •  执笔经年
    2020-12-18 21:57

    A quote from a related issue against The Rust Programming Language:

    You'd better think about if let as a one-handed match with no exhaustive checking enforced. It often has nothing to do with if or let, that's why it is so confusing. :)

    Maybe it would be better to rename the whole operator, call it match once or something like that.

    (slightly modified to make sense without the context)

提交回复
热议问题