首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Rust 1.26.2 发布,Mozilla 开发的系统编程语言

Rust 1.26.2 已发布,Rust 是一门专注于安全性,速度和并发性的系统编程语言。

如果你已安装过 Rust,升级至 Rust 1.26.2 非常方便

代码语言:javascript
复制
$?rustup?update?stable

该补丁版本修复了?match?表达式中的关于 ?borrow checker 的一个错误。这个 bug 是在 1.26.0 版本中引入的。具体来说,它允许代码在同一时间使用两个可变的?bar?路径。

代码语言:javascript
复制
let?mut?foo?=?Some("foo".to_string());
let?bar?=?&mut?foo;
match?bar?{
????Some(baz)?=>?{
????????bar.take();?//?Should?not?be?permitted,?as?baz?has?a?unique?reference?to?the?bar?pointer.
????},
????None?=>?unreachable!(),
}

1.26.2 将拒绝上面的代码,并显示以下错误消息:

代码语言:javascript
复制
error[E0499]:?cannot?borrow?`*bar`?as?mutable?more?than?once?at?a?time
?-->?src/main.rs:6:9
??|
5?|?????Some(baz)?=>?{
??|??????????---?first?mutable?borrow?occurs?here
6?|?????????bar.take();?//?Should?not?be?permitted,?as?baz?has?a?...
??|?????????^^^?second?mutable?borrow?occurs?here
...
9?|?}
??|?-?first?borrow?ends?here

error:?aborting?due?to?previous?error

详细更新说明请查看?https://blog.rust-lang.org/2018/06/05/Rust-1.26.2.html

  • 发表于:
  • 原文链接https://www.oschina.net/news/96799/rust-1-26-2-released
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券
http://www.vxiaotou.com