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.
This issue brought to you by the fantastic Brian Anderson and Alexis Beingessner!
What's cooking on master?
101 pull requests were merged in the last week. Woo!
Breaking Changes
- Flexible target specification has finally landed. This makes it much easier to create custom toolchains for unsupported platforms. RFC.
- Error interoperation improves the ergonomics of error handling when multiple error types are involved. RFC.
- The
rtio
abstraction layer that supported I/O on green threads has been removed. RFC. - There has been a minor breaking change to the serialization of tuples.
- Minor changes to macro interpolation have resulted the
removal the
$foo:matchers
type ofmacro_rules!
argument. - Socket construction is now more flexibly done through a ToSocketAddr type.
- Some changes have been made to the BytesContainer, which is used
to construct
Path
s, causing breakage is some cases. - The comparision types have been updated for DST, resulting in
changes to how they are invoked for references to unsized types
(i.e.
&str
and&[T]
). - As part of the recent collections overhaul, the prelude now contains a repeat function that returns an iterator that repeatedly yields the same value.
- Some changes to make overloaded operators behave more consistently will cause some previous code to break.
- The collections crate has seen major refactorings and updates as part of the collections overhaul. There was additional discussion about the impact on reddit.
- The json crate works with string slices instead of strings, and now overloads the index operator.
- A number of prelude traits have been renamed and consolidated as fallout from DST and to conform to new [conventions]. This should not break much code as these traits are rarely named explicitly.
- The rlibc crate, which provides a few libc functions expected to exist by LLVM's code generation, and is only useful for freestanding Rust projects, has been moved out of the main rust distribution, and now must be installed via cargo.
Other Changes
- New blanket impls of the unboxed closure types allow them to interoperate. See test cases for examples.
- impls can now be defined on trait objects.
- P1start has been converting compiler messages that provide suggestions from 'notes' to 'help' messages.
- The
exceeding_bitshifts
lint catches overlong shifts (which are currently undefined behavior) of static size. Due to bugs it is set to 'allow' be default. - Ariel removed a bunch of unsafe code from the compiler. Yay!
- A new
-l
flag to the compiler has been added to specify linkage to native libraries, primarily for use by cargo. In the same PR,include!
was updated to expand its arguments, allowing cargo to do for more complex compile-time code generation. RFC. #![cfg]
and#[cfg_attr]
can be applied to crates.- On x86 Linux, random number generation now prefers the new
[
getrandom
] syscall.
New Contributors
- Cristi Burcă
- juxiliary
- Nathan Zadoks
- qwitwa
- Sean Jensen-Grey
- Subhash Bhushan
- thiagopnts
- tshakah
- Vitali Haravy
- Vladimir Matveev
- whataloadofwhat
Approved RFC's
- Num reform: Strips down
std::num
to minimally support generic primitive numbers, without supporting a full mathematical hierarchy. - Higher-ranked trait bounds: Add the ability to have trait bounds that are polymorphic over lifetimes. Necessary for unboxed closures.
- un-feature-gating struct variants: Woo!
- Multiple lifetime bounds: Removes special cases from the type system and allows more complex lifetime relationships to be expressed that were previously only inferable.
New RFC's
- Macro reform: Prepares macros for 1.0 stabilization. Renames
macro_rules!
tomacro!
, and introduces more robust support for module importing and exporting. - Change integer fallback RFC to suggest
i32
instead ofint
as the fallback: Changes the fallback for performance and portability. - Un-feature-gate if let and tuple indexing: The features are well-behaved and used by many projects; ship 'em!
- Prohibit unused type parameters in impls: Require that every impl type parameter appears textually within the input type parameters of the trait reference or the impl self type.
- ES6-style unicode string escaping: Remove
\u203D
and\U0001F4A9
unicode string escapes, and add ECMAScript 6-style\u{1F4A9}
escapes instead. Strong positive feedback, some concern with how it interacts with format strings. - extension trait conventions: Establishes a definition and naming convention for extension traits: traits which aren't intended for generic programing, but instead extending existing types. If extending a
Foo
, useFooExt
. If Extending aFoo
when it impls another trait likeAdd
, useFooAddExt
. - cmp and ops reform: Refactors
Cmp
and the operator overloading traits. Generally positive feedback. Highlights include:- Make basic unary and binary operators work by value and use associated types.
- Generalize comparison operators to work across different types; drop Equiv.
- Refactor slice notation in favor of range notation so that special traits are no longer needed.
- Add IndexSet to better support maps.
- Clarify ownership semantics throughout.
- Change precedence of
+
in type grammar: Update type grammar to make+
have lower precedence, consistent with the expression grammar, resolving a grammatical ambiguity. - Relocate and improve c_str:
- Move the c_str module out of std to rid the latter of type dependencies on libc.
- Split the current CString into a low-level type CStrBuf and a length-aware CString to make computation costs explicit.
- Provide custom destructors and purpose-specific, mnemonically named constructors.
- Add some methods and trait implementations to make the types more useful.
- Remove the Clone implementation due to lack of purpose.
- rename
lifetime
toscope
: Highly controversial. Some community members argue that this change in terminology has been much more effective when introducing the actual concepts to newbies. Others argue that scope is already a well established concept in programming languages. - Finalizing more naming conventions: finalizes a few long-running de facto conventions, including capitalization/underscores, and the role of the unwrap method. Generally positive feedback, some discussion of naming consts like enum variants.
- Reserve macro identifiers: Preemptively reserve a class of $ identifiers for allowing backwards compatible improvements to the macro system.
Community
From the Team
- Weekly-meetings/2014-11-04 (macros; multiple lifetime bounds; macro invocation syntax; higher-ranked trait bounds; pub trait methods; out-of-sync nightlies; struct variants; numerics)
- Weekly-meetings/2014-10-30 (error conventions; cargo; namespaced enums; trait-based error handling; macro unification; coercions; dynamic linking, byte literals, failing dtors)
- IRC notifications now going to #rust-bots: If you have a bot you'd like to post here (which would be awesome!) please add a description and contact to the wiki page.
- Stability as a Deliverable
Videos
- An introduction to Servo: Lars Bergstrom from the Research team provides an overview of the Servo project, demonstrates its current status, and shows how to contribute to it.
- November's Bay Area meetup happened on Thursday, featuring five presentations about Servo and browser architecture.
Blog Posts
- This Week In Servo (10).
- Rewriting Rust Serialization, Part 2: Performance: A quick look at how Rust's JSON serialization performance compares to other languages and protocols.
- Improved Error Handling in Rust: Some discussion of how Rust currently and theoretically handles erroes.
- Don't Panic! The Hitchhiker's Guide to Unwinding: A nice discussion of the challenges of safe and ergonomic error handling, and how it relates to stack unwinding.
- Let's build a browser engine! Part 7: Painting 101: Part of a longer series on writing a browser engine in Rust. In this article, I will add very basic painting code.
- On pattern matching performance in Rust: A quick look at how the
match
statement can produce really efficient code. - Rust and Go: A quick look at Rust and Go from the perspective of a sysadmin used to high-level programming languages. Reddit. Hacker News
- Learning Rust: Inspired by Artyom's Learning Racket series, I've decided to log my efforts in learning Rust. I'm going to document my learning process as I go about trying to build a roguelike in Rust. I've downloaded the compiler, skimmed the getting started guide, and written “Hello World”. So let's get started!
Discuss
- Pre-RFC: placement box with Placer trait: Add user-defined placement box expression (more succinctly, "a box 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 temporary storage on the stack and then copying the datum from the stack into the backing storage).
- Forbid -(unsigned integer): the eternal struggle continues. It's super handy when you want it, but also a common error to make.
- Moving all built-in macros to plugins: Another proposal to handle some of the issues with macros for 1.0. May make it easier to bootstrap changes to the compiler.
- Lifetime Notation:
&'a
->a&
. Some discussion of tradeoffs and details. - Poll:
Foo::new()
vsFoo()
as the default constructor
- Warning! Some collection methods have had their semantics changed transparently!
- Error interoperation now available in the nightlies
- Trait-based Exception handling RFC postponed until after 1.0
- Cargo now supports build-scripts!
- What libraries would you like to see implemented in Rust?
- How good do you think the market for Rust developers will be 5 years from now, and in what area of programming?
- I think Rust and I were made for each other
- How does the Rust community feel about FFI?
- How do you refactor Rust code?
- I may start contributing to Rust...can I get a few pointers?
New Projects
- this-week-in-rust: This Week in Rust's content is now publicly hosted in a Github repo! If you find any errors, just submit a PR to the relevant markdown file in
/content
! If you'd like to help out, please contact cmr, brson, or Gankro on Github/Reddit/IRC. - rustaceans.org: This website is for finding Rustaceans. Wondering who is behind that GitHub username or IRC nick? Here is where to find out.
- rust-modifier: Convenient chaining APIs for free
- dockerfiles: Collection of lightweight and ready-to-use docker images
- Window Tiling For The Win: A tiling window manager written in Rust
- cxx2rs: A rust-binding generator for C/C++ files
- sorting-rs: This is a set of sorting algorithms, written in Rust.
- rust-chatserver: A barebone command line TCP chatserver written in Rust. Looking for feedback.
- rust-irc: A simple example irc implementation. Looking for feedback
- rusqlite: Ergonomic, semi-safe bindings to SQLite for Rust