A brace style that puts { on a new line if the function or if condition is multiline
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
In terms of the placement of the {, the following style is one I prefer to use. Examples by showing expected style below.
Expected (same line { when function signature is short - this is similar to existing SameLineWhere):
fn lorem(ipsum: usize) -> usize {
ipsum
}
Expected style (new line before { with multiline function signature)
fn format_with_overflow(f: &mut fmt::Formatter<'_>, length: usize, limit: usize,
separator: &str, ellipsis: &str,
fmt_elem: &mut dyn FnMut(&mut fmt::Formatter, usize) -> fmt::Result)
-> fmt::Result
{
Ok(())
}
Expected style - alternate (new line before { with multiline function signature)
fn format_with_overflow(
f: &mut fmt::Formatter<'_>, length: usize, limit: usize, separator: &str, ellipsis: &str,
fmt_elem: &mut dyn FnMut(&mut fmt::Formatter, usize) -> fmt::Result,
) -> fmt::Result
{
Ok(())
}
Description: Like SameLineWhere except newline before the opening brace if the function signature is multi-line.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining rustfmt's existing SameLineWhere behavior and how it detects multiline function signatures or if conditions. Compare the requested examples with current formatting, then determine the affected formatting paths and tests; done means the brace stays on the same line for short constructs and moves to a new line for multiline ones.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100