In keeping with their release model, the Rust development team has announced the first Rust release of 2016, 1.6. The biggest new feature that Rust 1.6 brings is libcore
stabilization, which aims to make it possible to use stable Rust for OS and embedded software development.
libcore
provides a low-level, platform agnostic foundations on top of which Rust standard library, libstd
, builds higher-level functionality such as memory allocation, I/O, and concurrency. As such, libcore
is the lowest-level layer that OS and embedded software developers often prefer basing their application on, and bringing stability to libcore
means thus providing stable foundations for such kind of lower-level software.
As Rust core team member Steve Klabnik told to InfoQ, the importance of this cannot be understated:
It’s the first big step towards making OS/embedded development work on stable Rust. So it’s important, but it’s still just the first step. I do think that demonstrating that Rust is a viable option at the lowest levels of software is important for its future.
An important caveat, though, is that libcore
currently supports only development of libraries, whereas applications are not fully supported yet. Klabnik explained to InfoQ, the reason why libcore
does not fully support applications lies with a few undefined “lang items” that it needs. In Rust, lang items can be thought of as linker symbols that can be used as “hooks” into the language itself. This make it possible, e.g., to implement part of Rust functionality in libraries and not in the language itself. According to Klabnik, this is no big deal for developers who want to build a library that does not use libstd
(no_std
). Indeed, he says:
We will probably not be adding these two [lang items] to
libcore
itself. They’re specifically for users to implement in the way that’s appropriate for them. If you are attempting to build an executable withno_std
, then you must define the two lang items yourself.
Klabnik also provided the link to a source file of his where he shows how those missing symbols can be defined:
#[lang = "eh_personality"]
extern "C" fn eh_personality() {
}
#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
loop {}
}
#[lang = "begin_unwind"]
pub extern "C" fn begin_unwind() {
}
Besides stable libcore
, Rust 1.6 adds a host of small refinements to library functions and language features, most notably the drain
family of functions, used to remove elements out of a collection while also retaining their backing memory, and new From
conversions. A full list of all changes can be read in the release notes.