3.2. 使用 rusrust 作为独立工具
使用 rusrust 作为独立工具格式化 Rust 源文件及其所有依赖项。另外,还可在 Cargo 构建工具 中使用 rus proprietaryt。如需更多信息,请参阅使用带有 Cargo 的 rusgdmt。
先决条件
-
现有的 Rust 项目。
有关如何创建 Rust 项目的详情,请参考 创建 Rust 项目。
流程
要使用 rusrust 作为独立工具格式化 Rust 源文件,请运行以下命令:
在 Red Hat Enterprise Linux 8 中:
$ rustfmt <source-file>-
将
<source_file> 替换为源文件的名称。
另外,您可以将 <source_file> 替换为标准输入。然后,rustedt 在标准输出中提供其输出。
-
将
在 Red Hat Enterprise Linux 9 中:
$ rustfmt <source-file>-
将
<source_file> 替换为源文件的名称。
另外,您可以将 <source_file> 替换为标准输入。然后,rustedt 在标准输出中提供其输出。
-
将
注意
默认情况下,rus distribution t 会修改受影响的文件,而不显示详细信息或创建备份。要显示详情并创建备份,请运行带有 --write-mode 值 的 rus proprietaryt。