




















The Rust team is happy to announce the latest version of Rust, 1.14.0. Rust is a systems programming language focused on safety, speed, and concurrency.
As always, you can install Rust 1.14.0 from the appropriate page on our website, and check out the detailed release notes for 1.14.0 on GitHub. 1230 patches were landed in this release.
One of the biggest features in Rust 1.14 isn't actually in the language or compiler: the rustup tool has reached a 1.0 release, and is now the recommended way to install Rust from the project directly. Rustup does a bit more than just install Rust:
rustup installs The Rust Programming Language from the official release channels, enabling you to easily switch between stable, beta, and nightly compilers and keep them updated. It makes cross-compiling simpler with binary builds of the standard library for common platforms. And it runs on all platforms Rust supports, including Windows.
We had a previous post about Rustup back in May. You can learn more about it there, or by checking it out on GitHub.
Another exciting feature is experimental support for WebAssembly as a
target, wasm32-unknown-emscripten. It is still early days, and there's a lot
of bugs to shake out, so please give it a try and report them! To give you a
small taste of how it works, once you have emscripten installed, compiling
some Rust code to WebAssembly is as easy as:
$ rustup target add wasm32-unknown-emscripten
$ echo 'fn main() { println!("Hello, Emscripten!"); }' > hello.rs
$ rustc --target=wasm32-unknown-emscripten hello.rs
$ node hello.js
The community has been doing interesting, experimental work in this area: see Jan-Erik's slides for the workshop he ran at Rust Belt Rust for some examples, or check out Tim's example of the classic TodoMVC project. This implementation builds off of his webplatform crate, which exposes the DOM to Rust.
Speaking of platforms, a large number of platforms have gained additional support:
For rustc:
mips-unknown-linux-gnumipsel-unknown-linux-gnumips64-unknown-linux-gnuabi64mips64el-unknown-linux-gnuabi64powerpc-unknown-linux-gnupowerpc64-unknown-linux-gnupowerpc64le-unknown-linux-gnus390x-unknown-linux-gnuAnd for std:
arm-unknown-linux-musleabiarm-unknown-linux-musleabihfarmv7-unknown-linux-musleabihfIf you're using one of these platforms, follow the instructions on the website
to install, or add the targets to an existing installation with
rustup target add.
These platforms are all 'tier 2', please see our page on platform support for more details.
Just like how the community is doing interesting work on the WebAssembly target, there's also neat things going on with increasing Rust's target support beyond what's listed above. xargo allows for easy cross-compilation of Rust to bare-metal targets. If you're writing an operating system in Rust, or doing something interesting on a microcontroller, xargo can make your life a lot simpler.
The landing of MIR over the last few releases means that a number of improvements to compile times have landed, with more coming in the future.
In the language, one small improvement has landed: support for RFC 1492. This small
addition lets you use .. in more places. Previously, say you had a struct like this:
struct Point {
x: i32,
y: i32,
z: i32,
}
In any context where you're doing a pattern match, you could use .. to ignore the
parts you don't care about. For example:
let p = Point { x: 0, y: 1, z: 2 };
match p {
Point { x, .. } => println!("x is {}", x),
}
The .. ignores y and z.
Consider a similar Point, but as a tuple struct:
struct Point(i32, i32, i32);
Previously, you could use .. to ignore all three elements:
let p = Point(0, 1, 2);
match p {
Point(..) => println!("found a point"),
}
But you could not use it to only ignore parts of the tuple:
let p = Point(0, 1, 2);
match p {
Point(x, ..) => println!("x is {}", x),
}
This was an inconsistency, and so with RFC 1492 stabilized, compiles fine as of this release. This applies to more situations than tuples; please see the RFC for more details.
There have been a number of additions to the standard library, but they don't fit into particularly nice categories for this release. Here's the highlights:
println!(), with no arguments, prints newline.
Previously, an empty string was required to achieve the same.Wrapping impls standard binary and unary operators on references, as well
as the Sum and Product iterators, making references to these
types easier to use.From<Cow<str>> for String and From<Cow<[T]>> for Vec<T>. These implementations make sense, but were not yet added..zip() specialization to .map() and .cloned() for improved performance.RefUnwindSafe for atomic types, as these types are
"unwind safe," though that wasn't obvious at first.Vec::extend to Vec::extend_from_slice for performance gains.HashMap random seeds. This helps to mitigate one type
of DDoS attack.HashMap is more cache-friendly, for
significant improvements in some operationsAdd<{str, Cow<str>}> for Cow<str>. We already support Add
for other string types, so not having it on Cow is inconsistent.See the detailed release notes for more.
As for Cargo, RFC 1721 has been implemented. Cargo will now pass along the
values printed by rustc --print cfg to build scripts. The motivation for this
feature is that Cargo can now compile objects for statically linking against
the msvcrt on the MSVC platform.
Cargo now works properly with a read-only CARGO_HOME.
Finally, Cargo will ignore the panic configuration for the test and
bench profiles. This is important because the test runner relies on
panics counting as failing tests, and so with panic=abort, a failing test
would abort the entire test suite.
See the detailed release notes for more.
We had 144 individuals contribute to 1.14.0. Thank you so much!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。