Hello and welcome to another issue of This Week in Rust! Rust is a systems language pursuing the trifecta: safe, concurrent, and fast. This is a weekly summary of its progress and community. Want something mentioned? Send me an email! Want to get involved? We love contributions.
The big news this week was that the central crate repository is now live. There was much discussion on Hacker News, /r/rust and /r/programming.
We also have a new guide to error handling.
What's cooking on master?
100 pull requests were merged in the last week.
Breaking Changes
- Enum variants are now namespaced by their type name, a major change. Enums in the standard library have been reexported in their old locations, for now at least. RFC. Reddit.
- Collections have been modified to no longer require the various
_equiv
methods, which are now deprecated. Methods that search by key and value now often take a generic type that implementsBorrowFrom
, which converts e.g. bothstr
andString
to&str
. RFC. - As part of ongoing DST-ification,
AsSlice
has been modified to work with unsized types. This breaks existing code becauseAsSlice
type vars should now be taken by reference. At the same time, some of the ops have been extended to work with unsized types. - The
str
methodslice_shift_char
's return type has changed slightly. - The
find_copy
andget_copy
methods ofHashMap
are deprecated.find_copy
can be performed withmap.get(&key).cloned()
, which converts theOption<&T>
returned byget
toOption<T>
, andget_copy
to simplymap[key].clone()
, which calls.clone()
on the value returned by reference from the indexing operator. - Runtime removal continues. Breaking changes here are mostly to code invoking the runtime directly.
- The
overloaded_calls
andunboxed_closure_sugar
feature gates have been combined into a singleunboxed_closures
gate. - Formatting has seen a stability pass with some minor breaking changes. RFC.
- The little-used
col!
macro is renamed tocolumn!
. - Non-ASCII lifetime identifiers are behind the
non_ascii_idents
feature gate as intended. - Struct variants can not be matched as if they were tuple variants.
- There have been several breaking changes and deprecations to
std::char
. - Likewise, there have been a number of changes to the code dealing with raw string and vector processing.
Other Changes
- Rust now supports higher-ranked trait bounds. This is necessary to make unboxed closures work, but the implications are quite complex. Read the RFC for details.
Vec
implementsWriter
andMemWriter
is deprecated.- All statics now support the
#[linkage]
attribute, which is behind thelinkage
feature gate. - Parts of rustc have been pulled into a new
rustc_trans
crate to reduce memory pressure. - All idents following literals are tokenized specially now as future proofing. RFC.
- Unboxed closures can be written with the sugared syntax.
New Contributors
- Andrew Cann
- Gleb Kozyrev
- Jashank Jeremy
- jmu303
- Joonas Javanainen
- jxv
- Nicholas Bishop
- oli-obk
- sheroze1123
- Simon Wollwage
- Vadim Petrochenkov
- we
Approved RFC's
- Higher-ranked trait bounds: Makes the type-system powerful enough to deal with unboxed closures as well as boxed ones.
- RFC to restrict placing an identifier after a literal.: Future-proofs syntax for literals
- Finalizing more naming conventions: snake_case-type stuff and
unwrap
vsinto_inner
- Change precedence of
+
in type grammar: Cleans up a some weird parsing interactions - cmp and ops reform: DST-ify operators, add multi-dispatch, make them by-value for
flexibility, add IndexSet, unify slice operators with
..
notation sugaring to special types, kill Equiv - Add a thread local storage module, std::tls: Introduces Scoped TLS and Owned TLS in a new thread_local module to replace the old design. Should have better perf, be more flexible.
New RFC's
- Release channels and feature staging: This RFC describes changes to the Rust release process, primarily the division of Rust's time-based releases into 'release channels', following the 'release train' model used by e.g. Firefox and Chrome; as well as 'feature staging', which enables the continued development of experimental language features and libraries APIs while providing strong stability guarantees in stable releases.
- path reform: This RFC reforms the design of the std::path module in preparation for API stabilization. The path API must deal with many competing demands, and the current design handles many of them, but suffers from some significant problems given in "Motivation" below. The RFC proposes a redesign modeled loosely on the current API that addresses these problems while maintaining the advantages of the current design.
- placement box with Placer trait for overloading: Add user-defined placement in expression (more succinctly, "an in expression"), an operator analogous to "placement new" in C++. This provides a way for a user to specify (1.) how the backing storage for some datum should be allocated, (2.) that the allocation should be ordered before the evaluation of the datum, and (3.) that the datum should preferably be stored directly into the backing storage (rather than allocating temporary storage on the stack and then copying the datum from the stack into the backing storage).
- Feature gate box patterns: Move box patterns behind a feature gate.The general idea is good, but the semantics aren't baked enough for 1.0.
- Add "function name macro": This RFC proposes the addition of a function! macro that expands to the function it's used in. This will greatly help error reporting.
Community
Karen Rustad found a wild rustacean.
From the Team
- Weekly-meetings/2014-11-18: cmp/ops; TLS; future-proofing literal parsing; ungating tuple indexing, if/while let; naming conventions; struct variants matching; for syntax for higher-order lifetimes; macros; type parameter grammar; better shepherding Reddit.
- Cargo: Rust's community crate host.
Videos
- Introduction to programming safe and efficient systems in Rust. Jakub Bukaj at Øredev.
Blog Posts
- Rust, Lifetimes, and Collections. Alexis Beingessner (aka Gankro), who has been driving the current modernization of the collections libs, talks about the design of collections in Rust. Reddit. HN.
- Chasing an EPROTOTYPE Through Rust, Sendto, and the OSX Kernel With C-Reduce. Reddit.
- Rust tools. Nick Cameron has been thinking about the state of Rust tooling. Reddit.
- Roguelike Tutorial in Rust: Part 5: Combat! Part III. Reddit.
Discussions
- What are the advantages of Rust over modern C++?
- What does 'unwrap' mean in Rust?
- How would a Rust application be able to properly react to low level failures, like memory allocation failure?
- The Race Towards 1.0 and The Standard Library.
- Is Rust recommended for beginners with 0 programming language experience?. TL;DR it depends.
- Feedback wanted: improved Rust error handling. More experiments from mitsuhiko.
- Benchmarks on different Map implementations for uint keys.
New Projects
- rust-eh. Python-like error tracebacks, from mitsuhiko.
- rust-incidents. More error experiments from mitsuhiko.
sl
, the classic Unix command, in Rust.- img_hash. Perceptual hashing of images.
- raw-rs. Utilities for manipulation of Rust core types.
- rust-uchardet. Encoding detection.
- Rust-Relay. IRC client library. Start your bots!
- cargo-do. Cargo plugin for running multiple commands at once.
- dbus-rs. D-Bus bindings.
- rusty-abstract-algebra.
- wire. An abstraction over TCP and binary serialization.
Project Updates
- This Week in Servo 12.
- Glium's design choices. Glium is a safe OpenGL wrapper.