What Is New in Rust 1.53
| Category | Highlights |
|---|---|
| New Features | IntoIterator for arrays, Or-patterns in match, Unicode identifiers, Cargo now detects the default HEAD branch name automatically |
| Improvements | Incremental compilation turned off by default on stable, several library APIs stabilized |
How can I iterate over arrays by value in Rust 1.53?
Arrays now implement the IntoIterator trait, so you can iterate by value directly.
In practice you can write:
for item in [10, 20, 30] {
println!("{}", item);
}
This also lets you pass arrays to any function expecting a T: IntoIterator, for example:
use std::collections::BTreeSet;
let set: BTreeSet<_> = [1, 2, 3].into_iter().collect();
Watch out for the legacy array.into_iter() method call: the compiler still treats it as (&array).into_iter() to avoid breaking existing code. The new behavior is fully available through the for loop syntax or IntoIterator::into_iter.
What new pattern matching capabilities does Rust 1.53 introduce?
Rust 1.53 adds support for nested | (or-patterns) anywhere inside a pattern.
This lets you collapse multiple arms into a single one, improving readability:
match result {
Ok(Some(1 | 2)) => println!("Got 1 or 2"),
Err(MyError { kind: FileNotFound | PermissionDenied, .. }) => println!("Access problem"),
_ => println!("Other case"),
}
Most teams will find this useful when handling enums with many similar variants, reducing boilerplate.
Can I use non-ASCII characters in identifiers with Rust 1.53?
Yes, identifiers may now contain any Unicode characters defined by UAX #31.
Examples include:
const BLÅHAJ: &str = "🦈";
struct 人 {
名字: String,
}
let α = 42;
The compiler emits warnings when identifiers are visually confusable (e.g., Latin s vs. full-width s), helping you avoid subtle bugs.
Does Cargo automatically detect the default branch name of git repositories in Rust 1.53?
Yes, Cargo no longer assumes the default branch is named master.
If a repository's default branch is main (or any other name), you can add it as a dependency without specifying branch = "main":
[dependencies]
my_lib = { git = "https://github.com/example/my_lib.git" }
This simplifies CI pipelines that mirror modern Git hosting defaults.
Why is incremental compilation disabled by default in Rust 1.53?
Incremental compilation remains off on the stable channel to keep the default toolchain lean and predictable.
If you need it, re-enable it by setting the environment variable CARGO_INCREMENTAL=1 or by adding incremental = true to your .cargo/config.toml. The feature is still available on beta and nightly builds.
Frequently Asked Questions
Is the IntoIterator implementation for arrays stable in Rust 1.53?
Yes, it is stable and ready for production use.
Do I need to change existing .into_iter() calls after upgrading to Rust 1.53?
No, the compiler still treats array.into_iter() as a reference iterator to preserve compatibility.
How do I write an or-pattern in a match statement in Rust 1.53?
Use the | syntax inside the pattern, for example match x { Some(1 | 2) => ... }.
Can I name a struct using Chinese characters in Rust 1.53?
Yes, identifiers can include Unicode characters such as struct 人 { 名字: String }.
Do I have to specify branch = "main" for git dependencies after Rust 1.53?
No, Cargo now automatically detects the default branch name.
How can I re-enable incremental compilation on the stable channel in Rust 1.53?
Set the environment variable CARGO_INCREMENTAL=1 or add incremental = true to your .cargo/config.toml.