


























The Rust team is happy to announce the latest version of Rust, 1.8. Rust is a systems programming language focused on safety, speed, and concurrency.
As always, you can install Rust 1.8 from the appropriate page on our website, and check out the detailed release notes for 1.8 on GitHub. About 1400 patches were landed in this release.
There are two new features in Rust 1.8, as well as good news for Windows users!
Additionally, work is underway to replace our make-based build system with
one based on Cargo.
The first feature is that the various “operator equals” operators, such as +=
and -=, are now overloadable via various traits. This change was accepted in
RFC 953, and looks like this:
use std::ops::AddAssign;
#[derive(Debug)]
struct Count {
value: i32,
}
impl AddAssign for Count {
fn add_assign(&mut self, other: Count) {
self.value += other.value;
}
}
fn main() {
let mut c1 = Count { value: 1 };
let c2 = Count { value: 5 };
c1 += c2;
println!("{:?}", c1);
}
This will print out Count { value: 6 }. Like the other operator traits, an
associated type allows you to use different types on each side of the operator,
as well. See the RFC for more details.
The second feature is very small, and comes from RFC 218. Before Rust 1.8, a
struct with no fields did not have curly braces:
struct Foo; // works
struct Bar { } // error
The second form is no longer an error. This was originally disallowed for consistency with other empty declarations, as well as a parsing ambiguity. However, that ambiguity is non-existent in post-1.0 Rust. Macro authors saw additional complexity due to needing a special-case, as well. Finally, users who do active development would sometimes switch between empty and non-empty versions of a struct, and the extra work and diffs involved was less than ideal.
On the Windows front, 32-bit MSVC builds now implement unwinding. This moves
i686-pc-windows-msvc to a Tier 1 platform.
Finally, we have used make to build Rust for a very long time. However,
we already have a wonderful tool for building Rust programs: Cargo. In Rust
1.8, initial support landed for a new build system that’s written in Rust,
and based on Cargo. It is not yet the default, and there is much more work to
do. We will talk about this in release notes more once it’s completely done,
for now, please read the GitHub issue for more details.
About 20 library functions and methods are now stable in 1.8. There are three major groups of changes: UTF-16 related string methods, various APIs related to time, and the various traits needed for operator overloading mentioned in the language section.
See the detailed release notes for more.
There were a few updates to Cargo:
cargo init can be used to
start a Cargo project in your current working directory, rather than making a
new subdirectory like cargo new.cargo metadata is another
new subcommand for fetching metadata about a project..cargo/config now has keys for -v and
--colorSee the detailed release notes for more.
We had 126 individuals contribute to 1.8. Thank you so much!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。