3.2. rustfmt をスタンドアロンツールとして使用
rust ソースファイルとそのすべての依存関係を rustfmt
ツールでフォーマットするには、以下を実行します。
Red Hat Enterprise Linux 7 の場合:
scl enable rust-toolset-1.35 'rustfmt source-file'
$ scl enable rust-toolset-1.35 'rustfmt source-file'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Red Hat Enterprise Linux 8 の場合:
rustfmt source-file
$ rustfmt source-file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
source-file を、ソースファイルへのパスに置き換えます。
デフォルトでは、rustfmt
は詳細を表示したりバックアップを作成したりせずに、影響を受けるファイルを変更します。動作を変更するには、--write-mode value
オプションを使用します。詳細は、rustfmt
のヘルプメッセージを参照してください。
Red Hat Enterprise Linux 7 の場合:
scl enable rust-toolset-1.35 'rustfmt --help'
$ scl enable rust-toolset-1.35 'rustfmt --help'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Red Hat Enterprise Linux 8 の場合:
rustfmt --help
$ rustfmt --help
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
また、rustfmt
はファイルの代わりに標準入力を受け付け、出力を標準出力で提供します。