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?

More than 3 years have passed since last update.

Rustの型宣言まとめ

Posted at

数値型

アルファベット1文字とビット数であらわす。
アルファベットは以下の意味を持つ。

  • i:符号あり整数
  • u:符号なし整数
  • f:浮動小数点型

u64 ⇒ 符号なし64ビットの整数

文字列型

strとStringがある。
コアライブラリの中で定義されているのはstrのみで、Stringは標準ライブラリで定義されている。

str

スライスと呼ばれるもの。
文字列のスタートのメモリ番地と文字列長を保持している。
変更不可なので、定数を定義しておき、その定数を&strの形で参照を保持するのに使うことが多い。

String

変更が可能な文字列型。
文字列操作を行う場合にはこちらの型を利用する。

タプル

複数の型の値を格納できる。
後述する配列は、特定の型の値しか保持できない。
タプルは内部の値の型を含めて一つの型として扱われるため、後から内部の値の型を変えることは出来ない。

配列

特定の型の値を複数格納できる。
配列サイズはコンパイル時に決まっている必要がある。

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?