「The Rust Programming Language」英文 備忘録 Chap3

「The Rust Programming Language」英文 備忘録 Chap3
Photo by Florian Olivo / Unsplash

3.2. Data Types

fn main() {
   let x: (i32, f64, u8) = (500, 6.4, 1);

   let five_hundred = x.0;

   let six_point_four = x.1;

   let one = x.2;
}

This program creates the tuple x and then accesses each element of the tuple using their respective indices.

indices [índəsìːz] indexの複数形

This is the same as writing let a = [3, 3, 3, 3, 3]; but in a more concise way.

concise [kənsάɪs] 簡潔な

3.3. Functions

Functions are prevalent in Rust code.

prevalent [prév(ə)lənt] 広く行き渡っている→広く使われている

Statements are instructions that perform some action and do not return a value.
Expressions evaluate to a resultant value.

instruction 命令
Statements 文
Expressions 式
evaluate to 〜 評価した結果〜になる→式は評価されて値を返す

Therefore, nothing is returned, which contradicts the function definition and results in an error.

contradict 矛盾

Rust provides a message to possibly help rectify this issue: it suggests removing the semicolon, which would fix the error.

rectify 修正する

3.4. Comments

All programmers strive to make their code easy to understand, but sometimes extra explanation is warranted.

strive 努力する

3.5. Control Flow

Repetition with Loops

repetition [rèpətíʃən] 繰り返し