- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 64字
- 2021-07-02 23:07:19
Passing by reference
A variable passed by a reference looks like this:
fn my_function(a: &i32, b: &i32) -> i32
We take two variables as references, and return a value.
To obtain a value from a reference, the first thing to do is dereference it. This is done with the asterisk (*) operator:
let ref_num = &2; let deref_num = *ref_num; // deref_num = 2
推薦閱讀
- Getting Started with ResearchKit
- Java面向對象思想與程序設計
- Practical Data Science Cookbook(Second Edition)
- oreilly精品圖書:軟件開發者路線圖叢書(共8冊)
- Python金融數據分析
- Linux網絡程序設計:基于龍芯平臺
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- 微信小程序項目開發實戰
- Gradle for Android
- Visual C++開發入行真功夫
- 區塊鏈技術進階與實戰(第2版)
- Mastering Adobe Captivate 7
- Mastering Leap Motion
- Android嵌入式系統程序開發(基于Cortex-A8)
- Joomla!Search Engine Optimization