3.2. 使用 rusrust 作为独立工具
使用
rusrust 作为独立工具格式化 Rust 源文件及其所有依赖项。另外,还可在 Cargo 构建工具
中使用 rus proprietaryt。如需更多信息,请参阅 使用
Cargo 构建工具。
先决条件
流程
格式化 Rust 源代码:
rustfmt <source-file>
$ rustfmt <source-file>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将
<source_file
> 替换为源文件的名称。另外,您可以将 <source_file>
; 替换为标准输入。然后,
rustedt 工具在标准输出中提供其输出。重要默认情况下,rus
distribution
t 会修改受影响的文件,而不显示详细信息或创建备份。要显示详情并创建备份,请使用--write-mode 选项运行 rus proprietary
t。