Next to `start..=end`, you can now also use `start..` as a pattern to match on:
🦀 2. A better and faster floating point parsing algorithm in the standard library.
Functions like f64::from_str are now much faster, and a bunch of edge cases that failed to parse before are solved:
🦀 3. No more duplicate errors.
Cargo invocations like `cargo test`, which check multiple configurations of the the code, will no longer produce duplicate diagnostics, and instead only report the number of duplicates:
🦀 4. No more ErrorKind::Other errors from std.
The Other io::ErrorKind is now only for custom errors, and std no longer produces such io::Errors. Uncategorized errors can no longer be directly matched on, such that we can categorize them later without breaking things each time.
🦀 5. The array.map function.
Iterators already had a `.map()` function, but that would result in an iterator, not an array, which does not statically know its length anymore. If you want to map the values of a [T; 3] to some [U; 3], you can now use `.map()` directly on arrays:
🦀 6. std::ops::ControlFlow.
An enum with two variants: Break and Continue. It is similar to Result, but without calling the cases 'okay' and 'error'.
It's part of the larger 'try v2' feature which is still in development. It can already be used through `iterator.try_for_each`:
🦀 7. A few methods on MaybeUninit.
.write() allows you to write into a MaybeUninit and get a &mut T to what you wrote, without writing any unsafe blocks.
.assume_init_ref() and .assume_init_mut() are unsafe, but allow you to get a reference without first needing a raw pointer.
🦀 8. const std::str::from_utf8_unchecked.
The unsafe from_utf8_unchecked function is now const. If you're sure that some bytes you already have at compile time are valid utf-8, you can now directly turn them into a static or const &str:
🦀 9. cargo clippy --fix
Just like `cargo fix` applies the suggestions from Rustc's warnings, `cargo clippy --fix` will automatically apply the suggestions from Clippy to your code:
And with that, I'm ending this thread. 🧵🏁
For more details and all the other changes and additions in Rust 1.55.0, see the announcement and the release notes:
We already had str::split and str::splitn, which result in an iterator. But when parsing something simple, you often want to split something exactly once. For example, to parse a string containing `key=value`.
2/10
Another one I'm excited about is one of the first features I worked on: std::fmt::Arguments::as_str()
fmt::Arguments is returned by format_args!(), and appears in macros that support formatting.
as_str() allows handling the literal case without special-casing your macro:
I just approved the PR for a very exciting addition to @rustlang 1.53: IntoIterator for arrays 🎉🦀
Before this change, only references to arrays implemented IntoIterator, which meant you could iterate over &[1,2,3] and &mut [1,2,3], but not over [1,2,3] directly.
1/6
The reason we didn't add it sooner was backwards compatibility. `array.into_iter()` already compiles today, because of the way methods get resolved in Rust. This implicitly calls `(&array).into_iter()`. Adding the trait implementation would change the meaning and break code.
2/6
Technically we consider this type of breakage (adding a trait impl) 'minor' and acceptable. But there was too much code that would be broken by it. Thanks to @LukasKalbertodt, such code results in a warning nowadays, but there's a lot of code that just doesn't get updated.