[][src]Struct show_notes::news::rust_1_21_1_22::Script

pub struct Script;

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!

1.21

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:

1.22

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.

Wasm!

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 lib.rs item in the root of your crate:

#![doc(include="../README.md")]

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!

Outro

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:

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 newrustacean.com/show_notes/news/rust_1_21_1_22/. I'm on Twitter and GitHub @chriskrycho, and the show is @newrustacean on Twitter. You can also email me at [email protected] 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

impl Send for Script

impl Unpin for Script

impl Sync for Script

impl RefUnwindSafe for Script

impl UnwindSafe for Script

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]