Rust 1.14 introduces WebAssembly as a new experimental target and extends the ..
syntax for pattern matching, writes the Rust core team.. Additionally, rustup
is now stable and is the recommended way to build Rust from sources.
WebAssembly, a low-level, portable bytecode that aims to enable execution at near-native speed by relying on common hardware capabilities that are available on many platforms, is now supported by Rust through the new wasm32-unknown-emscripten
compilation target. This allows developers to compile Rust to WebAssembly by executing:
$ rustup target add wasm32-unknown-emscripten
$ echo 'fn main() { println!("Hello, Emscripten!"); }' > hello.rs
$ rustc --target=wasm32-unknown-emscripten hello.rs
This will output a hello.js
file that can be run using node
. WebAssembly support is still experimental, as mentioned, and there are parts of the Rust runtime that are not available at all, such as Rust’s I/O stack. WebAssembly support requires emscripten, which can be installed by running:
curl -O https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
tar -xzf emsdk-portable.tar.gz
source emsdk_portable/emsdk_env.sh
emsdk update
emsdk install sdk-incoming-64bit
emsdk activate sdk-incoming-64bit
On the language front, Rust 1.0 extends the syntax for the ..
pattern matching operator, which now can be used to selectively ignore parts of the context where it appears. For example, the following code is now correct and makes it possible to match x
while ignoring both the y
and z
components of the Point
tuple:
struct Point(i32, i32, i32);
let p = Point(0, 1, 2);
match p {
Point(x, ..) => println!("x is {}", x),
}
Previously, the ..
operator could be only used to ignore all elements, e.g.:
let p = Point(0, 1, 2);
match p {
Point(..) => println!("found a point"),
}
Another significant feature of Rust 1.14 is rustup
1.0, which is now deemed stable. Rustup is a command-line application that is able to download and switch between different versions of the Rust toolchain –i.e., its compiler, rustc
, and the standard library– for a number of supported platforms.
Rust 1.14 release contains more than 1200 patches that are detailed in the official release notes.