新功能介绍:
Rust 1.19.0 首个支持 unions 的版本:[code]union MyUnion {
f1: u32,
f2: f32,
}[/code]Unions 与枚举有点类似,但 Unions 是“untagged”的。
除此之外,loops can now break with a value[code]// old code
let x;
loop {
x = 7;
break;
}
// new code
let x = loop { break 7; };[/code]Rust 将自己定位为“面向表达式的语言”,新的版本中,循环使用了这样的方式。
其他新特性
String now implements FromIterator
Vec now implements From<&mut [T]>
Box<[u8]> now implements From
SplitWhitespace now implements Clone
软件详情:https://blog.rust-lang.org/2017/07/20/Rust-1.19.html
下载地址:https://www.rust-lang.org/en-US/install.html
来自:开源中国社区