BT

Rust 1.14 Brings Experimental WebAssembly Support and Rustup 1.0

| by Sergio De Simone Follow 14 Followers on Dec 23, 2016. Estimated reading time: 1 minute |

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.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT