pub struct Script;
Expand description

News: Rust 1.21 and 1.22

Hello, I’m Chris Krycho, and this is New Rustacean, a show about the Rust programming language and the people who use it. This is a news episode about Rust 1.21 and 1.22.

Listeners will notice that this has two releases in it and that I missed the 1.21 release. There’s a good reason for that! I was moving across the country and prepping for Rust Belt Rust, which was a fabulous conference. If it happens again next year, you should definitely go: it was a really nice event, large enough to be interesting but small enough that you could meet many of the people there. And the micro-interviews I recorded there, which this will come out right in the middle of, were a blast—it was neat to see just how wide the range of attendees were, from one person I interviewed who had done no Rust at all before showing up to others who had been there since well before 1.0.

And now, let’s talk about news that has happened through the interval while Rust 1.21 and 1.22 came out!


Rust 1.21 came out on October 12, 2017. As is often the case, it wasn’t an especially large release, and as usual that’s no bad thing! 1.21 was essentially a “quality-of-life” improvement in a couple areas:

  • There are some places where locally-declared variables could be treated as static and just work instead of being stack-allocated and therefore having local scope lifetimes… well, now they are treated as static and just work. This is one of the many small things that the Rust compiler team has done as part of this year’s ergonomics initiatives that take things that intuitively seem like they should be fine, and smarten up the language so they are fine.

  • The standard library now includes the for_each method on the Iterator trait. For a long while, you’ve been able to do this via a crate, but it’s super handy to have it present in the standard library. Often you just use a for loop, but sometimes, when you’ve chained a bunch of iterator calls together, and you want to do some effectual operation at the end of them, having a .for_each call at the end of that chain is super handy.

  • 1.21 was the first release to support shipping the preview of the Rust Language Server via rustup. And the RLS is coming soon to stable – Nick Cameron wrote a blog post titled “When will the RLS be released?” between the 1.21 and 1.22 releases indicating it should be in a non-preview, stable state by early 2018. I’ve linked that blog post in the show notes so you can get the details!

  • One other neat little library stabilization: you can now use the function std::mem::discriminant to be able to check the specific discriminant of an enum type, which lets you compare whether two items are the same variant of enum, without bothering with the equality of the underlying data, and without needing to do a match expression. This isn’t a super common need, but even in my still relatively limited experience, it’s something I’ve wanted!

  • Finally, Cargo got a nice little feature for supporting a pretty common use case: where you need to patch a particular feature, and it hasn’t gotten upstreamed yet. You can just use the [patch] key in your Cargo.toml to override where to look up a given dependency.


Rust 1.22 was a nice Thanksgiving present, for those of us in the United States: it came out November 22 (not on a Thursday, like normal, since that was the holiday). Like 1.21, this is a relatively small release, but the main quality-of-life feature in this one will make a pretty big difference in a lot of the code we write.

That feature is the first stable implementation of the Try trait for something besides Result. You might better know the Try trait as the trait which makes the ? operator work as a quick-return for functions when you have a bunch of different Results and want to quickly return Err cases and proceed only if you have an Ok case. Rust 1.22 stabilizes impl Try for Option, so you can now use ? to do the same kind of immediate-return if you have a None and continue through the body of your function only if you have a Some. This bit of trait-based syntactic sugar helps a ton when you have a function with an Option return type, and which has a number of places where it might return None.

In the future, you’ll actually be able to freely use it with a mix of both Option and Result return types, since Result and Option both implement the Into and From traits for each other. That’s not there with 1.22… but it is there on nightly! Coming Soon™️.

One other important note about 1.22: you’ll just get this automatically if you’re using rustup (and for the most part, you should just be using rustup!), but there are two 1.22 releases: 1.22.0, the normal release, and 1.22.1, which fixed a problem in Cargo with the latest version of macOS. rustup update stable will give you 1.22.1 automatically.

Other news

So that’s Rust proper! But there are some other neat things going on around the ecosystem since Rust 1.20 came out, too.

One fun thing I wanted to mention again after mentioning it in my special 50th episode is Rusty Spike: Jonathan Turner’s weekly Rust news podcast. The episodes are roughly 3–7 minutes long, and Jonathan has settled into a really nice rhythm and routine with the episodes. It’s a great show, and it covers things at a much more granular level than these New Rustacean news episodes do, so I think they end up being nicely complementary. I strongly encourage you to check it out!

Rust conferences

We’ve seen the end of the Rust conference season for the year, with the fall RustFest event in Zurich back at the end of September and, as I mentioned at the start of the episode, Rust Belt Rust at the end of October. The videos from RustFest are already up, so you can check those out. Videos from Rust Belt Rust are not out yet, but keep your eyes on their YouTube channel – last year they came out a couple months after the conference, and that seems pretty common. In the meantime, if you want to see the content for my talk at Rust Belt Rust, both the slides and the script are on my personal website.

The Failure crate

Since Rust came out, people have been iterating on the best ways to do error-handling in large projects. The Result type is really nice for making sure you have type-level control over the ways your errors are handled, but there are two downsides to using Results throughout your codebase:

  1. You can end up with a Result wrapping a huge variety of error types as their own enum, to account for all the different types of errors that can crop up in your library or application while still having a single Result type you can use throughout.
  2. Or you can end up with a bunch of different, much more specific Result error types, and then write a bunch of conversions between those error types for transitions between different parts of your library or application.

Both of those involve a lot of boilerplate. They work, and for all the reasons we’ve talked about before on the show they’re very much preferable to exceptions. But it’d be nice to not have to write so much of that boilerplate while still getting those benefits.

For the first couple years of Rust 1.x, the go-to solution has been the Error Chain crate. As people used it in practice, a number of limitations and frustrations reared their heads—and so Rust contributor withoutboats recently released the Failure crate, which aims to improve on the design of Error Chain. I plan to dedicate a Crates You Should Know episode to Failure at some point relatively soon. It’s an exciting development in the ergonomics initiative this year, and even if the crate is still pretty early in its development, it looks really nice.


Next up: WebAssembly! WebAssembly, or wasm, is a format for targeting browsers with compiled code. Just last week, Alex Crichton added early support for compiling to wasm directly from the Rust compiler. While you’ve been able to compile to wasm with Rust for a while, it’s been a hairy process involving a tool called emscriptem, which was really designed for C and C++ toolchains, and specifically for things like porting games to the browser. Many (perhaps even most) places we’d want to use Rust don’t need all the extra runtime pieces that emscriptem supplied, so now we can ship zero-runtime Rust code straight into browsers using the Rust compiler itself. For someone like me, who writes TypeScript all day every day and would love to be able to add Rust to my client-side toolbox, this is just incredibly exciting. I’ll definitely have a whole episode on this in the next few months. Note that this is very much early support, and lots of things probably won’t work. But it’s a very important step.

Some inbound changes with Rustdoc

Last but not least, is something contributed by the community via the RFC process: support for pulling in external Markdown documents as documentation for any given item. The single most obvious win from this is reusing your README as the source for the docs for the crate itself. Up to now, if you wanted your README and your main crate docs to be the same, you had to manually copy it back and forth between the two. Now, on nightly (and hopefully it’ll land on stable in the next few releases), you can just mark any item with a doc include attribute pointing to the file location relative to the src directory, and it’ll pull that text in for you as documentation. So, for your README, you might add this line to the item in the root of your crate:


In other words, it’s just a normal attribute with an argument! (If you need a refresher on attributes, you can go back and listen to episode 7, where I introduced them.)

This is something I have wanted for ages, and I’m incredibly excited about it. Not least, because as a result, the script for this show and all future shows (and, soon, previous episodes too) is attached to the show notes for the episode, on the Transcript struct! So to see it in practice, all you need to do is look at the source for this episode. I’ve had scripts for most episodes, but attaching them was a fair bit of manual work, and I just hadn’t made the time to do it—now I don’t have to!


And that’s a wrap on this news episode. The next news episode should come out in about six weeks when Rust 1.23 comes out! In the meantime, I hope you enjoy the remaining Rust Belt Rust micro-interviews, and you can also look forward to three interviews with participants in the Increasing Rust’s Reach program, which will be released throughout December.

Thanks as always to this month’s $10-or-more sponsors:

  • Aaron Turon
  • Alexander Payne
  • Anthony Deschamps
  • Chris Palmer
  • Behnam Esfahbod
  • Dan Abrams
  • Daniel Collin
  • David W. Allen
  • John Chandler
  • Matt Rudder
  • Nathan Sculli
  • Nick Stevens
  • Oluseyi Sonaiya
  • Peter Tillemans
  • Olaf Leidinger
  • Raph Levien
  • and Vesa Khailavirta

If you’re enjoying the show, please tell others about it so they can learn about Rust. You can also support the show by recommending it in podcast directories like iTunes, or by sharing it on social media.

You can find show notes for this episode, including the episode script, at I’m on Twitter and GitHub @chriskrycho, and the show is @newrustacean on Twitter. You can also email me at I’ve got a good stockpile of show ideas from people sending me requests that way; please keep it up.

Until next time, happy coding!

Auto Trait Implementations§

Blanket Implementations§


impl<T> Any for Twhere T: 'static + ?Sized,


fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

impl<T> Borrow<T> for Twhere T: ?Sized,


fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for Twhere T: ?Sized,


fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more

impl<T> From<T> for T


fn from(t: T) -> T

Returns the argument unchanged.


impl<T, U> Into<U> for Twhere U: From<T>,


fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.


impl<T, U> TryFrom<U> for Twhere U: Into<T>,


type Error = Infallible

The type returned in the event of a conversion error.

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,


type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.