Rustfmt adds support for let-else statements
Rustfmt, the Rust code formatter, will soon include support for formatting let-else statements. This feature will be available starting with the nightly 2023-07-02 toolchain and is expected to be part of the stable Rust 1.72 release.
Let-else statements were introduced in Rust 1.65.0, but until now, Rustfmt did not have formatting support for them. As a result, developers had to manually style these statements. With the upcoming update, Rustfmt will automatically apply the let-else formatting rules.
The addition of let-else formatting support addresses a long-standing request from the Rust community. The Rust project has implemented measures to ensure that formatting support is provided more promptly after feature stabilization.
For developers using Rust, this update will streamline their coding process and maintain consistent formatting across their projects. Here's an example of how a let-else statement will be formatted by Rustfmt:
let result = if condition {
// code block for if branch
...
} else {
// code block for else branch
...
};
This improvement aligns with Rust's commitment to providing a clean and readable codebase. Developers can refer to the official Rust Style Guide for more information on the default formatting style for Rust code.