官术网_书友最值得收藏!

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 
主站蜘蛛池模板: 城口县| 湖南省| 稻城县| 昭通市| 海伦市| 辽宁省| 寻甸| 罗山县| 临江市| 平利县| 张家港市| 东乌珠穆沁旗| 钟祥市| 揭东县| 米易县| 巴东县| 铜陵市| 竹山县| 霍州市| 泗阳县| 鄂尔多斯市| 泰兴市| 大竹县| 汝州市| 胶州市| 永丰县| 广汉市| 红原县| 肥城市| 阳高县| 新余市| 永寿县| 宁阳县| 阳谷县| 防城港市| 太原市| 易门县| 隆昌县| 准格尔旗| 东山县| 红桥区|