Note di Hongmu

rustfmt

格式化 Rust 源代�

100% Elaborazione locale nel browser 0 Caricamento dei dati

Esempi comuni

格式化文件,就地覆盖原始文件

rustfmt {{路径/到/源文件.rs}}

检查文件的格式并在控制台显示所有变更

rustfmt --check {{路径/到/源文件.rs}}

在格式化前备份所有修改的文件(原始文件会以 `.bk` 扩展名重命名)

rustfmt --backup {{路径/到/源文件.rs}}

使用特定的 Rust 风格版次(格式化规则)以详细模式格式化代码

rustfmt --style-edition {{2015|2018|2021|2024}} {{[-v|--verbose]}} {{路径/到/源文件1.rs 路径/到/源文件2.rs ...}}

使用特定的 Rust 版次(语言特性和解析)格式化代码

rustfmt --edition {{2015|2018|2021|2024}} {{路径/到/源文件1.rs 路径/到/源文件2.rs ...}}

Suggerimento: parentesi graffe{{…}}È il parametro da sostituire (percorso, nome file, ecc.); il comando viene eseguito solo nel terminale locale e questo sito non salva alcun input.

Confronto del testo originale inglese

Espandi istruzioni ed esempi in inglese (fonte tldr-pages)

Format Rust source code. More information

Format a file, overwriting the original file in-place

rustfmt {{path/to/source.rs}}

Check a file for formatting and display any changes on the console

rustfmt --check {{path/to/source.rs}}

Back up any modified files before formatting (the original file is renamed with a `.bk` extension)

rustfmt --backup {{path/to/source.rs}}

Format code using a specific Rust style edition (formatting rules) verbosely

rustfmt --style-edition {{2015|2018|2021|2024}} {{[-v|--verbose]}} {{path/to/source1.rs path/to/source2.rs ...}}

Format code using a specific Rust edition (language features and parsing)

rustfmt --edition {{2015|2018|2021|2024}} {{path/to/source1.rs path/to/source2.rs ...}}

informazioni sul comando

nome del comandorustfmt
Utilizzo格式化 Rust 源代�
Piattaforme applicabili通用
Numero di esempi5 articolo
Documentazione ufficialehttps://github.com/rust-lang/rustfmt
Fonte dei datitldr-pages(CC-BY-4.0)· Traduzione cinese comunitaria

Domande frequenti

rustfmt Cosa fa il comando?

格式化 Rust 源代�

rustfmt Come usarlo?

Pagine elencate per scena5Esempi di uso comune: ogni esempio spiega prima lo scopo e poi fornisce un comando completo che può essere copiato direttamente (i parametri che devono essere sostituiti sono tra parentesi graffe).

rustfmt Quali sono le operazioni più comunemente utilizzate?

格式化文件,就地覆盖原始文件:rustfmt {{路径/到/源文件.rs}}

Cosa significano le parentesi graffe nel comando?

parentesi graffe{{…}}Indica che è necessario sostituirlo con il proprio valore, come percorso e nome file; parentesi quadre per i parametri con lo stesso nome (come[-C|--directory]) indica la scrittura facoltativa.