1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

本記事ではRustでOS情報やアーキテクチャなどを取得する方法を記載しています。

stdクレート

Rustの標準モジュールであるstdを用いて取得します。

use std::env::consts;
fn main(){
    let OS = std::env::consts::OS;
    println!("{}",OS);
}

std::env::constsでは以下の情報が取得できます。

  • OS:OS情報(バージョンやディストリビューションまでは取得しません。)
  • ARCH:CPUのアーキテクチャ
  • EXE_EXTENSION:ファイルの拡張端子を取得します。
  • DLL_PREFIX:動的ライブラリの接頭辞を取得します。
  • DLL_EXTENSION:動的ライブラリの拡張端子を取得します。
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?