Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

2015.06.10の活動

Toshihiro Kamiya edited this page Jun 11, 2015 · 4 revisions

進捗

2.Primitives
3.Custom Types
4.Variable Bindings
5.Casting

備忘録

2.Primitives

  • タプルは要素ごとに型を指定 (i32, bool)
  • 配列とスライス ary: [i32; 5]slice: &[i32]
  • 配列からスライスを生成 &ary[1 .. 4]

3.Custom Types

  • struct → 構造体、クラス

  • enum → 列挙型、 代数データ型

  • モジュールと可視性

  • structは要素に名前をつけるもの struct Point { x: f64, y: f64 } とつけないもの struct Pair(i32, f64);

  • モジュールを作ると外からは不可視(private)になる。pubキーワードをつけると見えるようになる

  • コンストラクタ impl<T> BlackBox<T> pub fn new(contents: T) -> BlackBox<T> { .... }

  • 代数データ型としてのenum、名前付きunion、パターンマッチmatch

  • 列挙型としてのenum

  • 文字列定数 static LANGUAGE: &'static str = "Rust";

4.Variable bindings

  • スコープ { .... }
  • mut

5.Casting

  • std::mem::size_of_val(&x)
  • as
  • type NanoSecond = u64;

積み残し

3.2 Enumで登場したBox