Announcing Rust 1.42.0

We're happy to announce the release of Rust 1.42.0, featuring better panic messages when unwrapping, subslice patterns, and more! Check out the highlights on the blog:

14 Likes

Happy to announce: fortytwo, the crate so you don't panic when using Rust 42.

3 Likes

Sub slice matching is nice! What's the @ notation though?

The @ notation is called @binding in the book.

3 Likes

What if I lost my towel?

1 Like

What sweet coincidence.

Hitch Hikers Guide to the Galaxy was 42 years old a few days ago.

"42" and "Panic" are of course something of a theme in HHG2G.

2 Likes

I'm a little unclear about what is included and what isn't.

Are or-patterns part of this release?
What about by-ref and move bindings in the same match?
If either of them isn't part of this release, when are they planned to be released?

Minor nitpick: I miss that the matches! macro does not support an optional leading | before the first pattern:

matches!(
    expr,

    | SomeFirstPattern
    | SomeOtherPattern
    | ...
);

This would be consistent with Rust syntax elsewhere:

match expr {
    | SomeFirstPattern $(=> ...)?
    | SomeOtherPattern => ...
}

I am aware that this leading pipe is a matter of style, and that it does not match the canonical format of, for instance, rustfmt, but I have found this kind of pipe-before-pattern very useful when enumerating: in the same fashion that lacking trailing commas is annoying as soon as you want to append a new line to the enumeration, this lack of a leading pipe is annoying in breaking the "symmetry":

matches!(
    expr,

    SomeFirstPattern 
    | SomeOtherPattern
    | YetAnotherPattern
    | ...
);
// or
matches!(
    expr,

    SomeFirstPattern |
    SomeOtherPattern |
    YetAnotherPattern |
    ... |
    LastPattern
);
3 Likes

Neither feature is part of this release.

1 Like

Or patterns tracked here: https://github.com/rust-lang/rust/issues/54883
Move-ref patterns tracked here: https://github.com/rust-lang/rust/issues/68354

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.