0
0

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のGlobal変数について #3

Posted at

はじめに

Rustにも変数と定数が存在します。

  • 変数
    • 関数内のみ記載することができる。
  • 定数
    • グローバルスコープで記載する

使い方

// ここで宣言
const HOGE: &str = "hogehoge island";

pub fn main() {
    println!{"{}", HOGE} // hogehoge island
}

制約について

  • 定数名は大文字で記載
  • 定数の値はコンパイル時に決定される必要がある
  • 型は明示的に記載する必要がある
  • constで記載する

以上です。
最後まで読んでいただきありがとうございました。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?