2,617
次編輯
Tankianting(討論 | 貢獻) |
Tankianting(討論 | 貢獻) |
||
行 72: | 行 72: | ||
num library有複數。 | num library有複數。 | ||
<pre> | |||
Complex<T>{ | Complex<T>{ | ||
re:T, //實部 | |||
im:T // 虛部 | |||
} | |||
Complex<f32> // 用f32存 | |||
let c = Complex{re: 0.24, im 0.3}; | |||
c.re == 0.24; | |||
c.im == 0.3; | |||
</pre> | |||
enum Option<T>{ | |||
None, | |||
Some(T), | |||
} | |||
比較 | |||
{| | |||
|result | |||
|option | |||
|- | |||
|Ok(x) | |||
|Error | |||
|- | |||
|Some(x) | |||
|None | |||
} | |||
<pre> | |||
let x = (2,3) // tuple | |||
//x.0 == 2 第0個元素 | |||
//x.1 == 3 第1個元素 | |||
</pre> | |||
<pre>2.0 as f64 // 強制指定型別</pre> | |||
[https://github.com/crossbeam-rs/crossbeam crossbeam]:建構concurrency的函式庫 | |||
[[category:資訊]] | [[category:資訊]] |