Formatting config option: `force_explicit_return`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start by locating the existing force_explicit_abi configuration option and the formatter entry points for function bodies and branches. Done means the new option consistently adds explicit return statements for the shown value-returning and unit-returning examples, with coverage for branching cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Request
Summary
I'd like the option to force all branches of all functions to use the optional return keyword.
Motivation
I think explicitly stating return rather than relying on the implicit behavior of {} blocks makes code easier to understand at a glance, and especially if there are complicated branching statements inside. (Admittedly, this is mostly a style preference, so I understand that it probably won't be a high-priority change.)
For a toy example, the proposed formatting option should change this:
fn add_one(x: u32) -> u32 {
x + 1
}
fn foo() -> () {
println!("This function has no return value!");
}
to this:
fn add_one(x: u32) -> u32 {
return x + 1;
}
fn foo() -> () {
println!("This function has no return value!");
return;
}
This syntax is more familiar to developers with backgrounds in other languages, such as C/C++, and follows the common Rust pattern that explicit is better than implicit.
Related configuration options
I wasn't able to find anything that was directly related to my proposed option, but it would follow in the spirit of options like force_explicit_abi.
- Lingua principale
- Rust
- Stelle
- 7.1k
- Fork
- 1.2k
- Merge medio
- 1g 4h
- PR unite (30g)
- 20
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rust-lang/rustfmt
-
A-config C-bug SO-print-config
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
A-Unicode C-bug P-low
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
rust-lang/rustfmt#7210 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
A-imports C-bug E-hard I-non-idempotency X-impacts-stable-default-format
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rust-lang/rustfmt#7173 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
A-comments C-bug only-with-option UO-indent_style
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Fix `first_line_width` to be tab-awareForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. ApertaA-tabs A-whitespace C-bug SO-hard_tabs
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/rustfmt
Issue simili
-
bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug core-lang
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Windows microphone listing treats words in a device name as DirectShow labelsForse già presa @Sujal-chaudhary l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
clipy-recorder/clipy#447 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
nightly-cleanup
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
max-sixty/worktrunk#4939 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno