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

What about functions with arguments?

Consider the following piece of code:

    fn main() 
    { 
        let a = 32; 
        let b = &a; 
    } 

We have created two variable bindings, with the second one (b) pointing at the address for a. The b variable doesn't contain the value of the a variable, but it points to the position a is held at, from which it can obtain a value (in other words, the value of b is borrowed from a).

In terms of our stack diagram, we have this:

The i binding points to address 0 and the b variable points to address 0, and this is the parameter being passed to second.

We can use this stack method to think about memory for a complex situation if you like.

主站蜘蛛池模板: 普兰店市| 肥乡县| 海林市| 井陉县| 武川县| 宣武区| 灵宝市| 宁海县| 嘉义县| 涟源市| 淄博市| 固阳县| 茂名市| 普陀区| 银川市| 遂溪县| 峨山| 余姚市| 伊宁县| 沾化县| 堆龙德庆县| 西昌市| 海城市| 巴中市| 安塞县| 巨鹿县| 鱼台县| 永川市| 思南县| 吉木萨尔县| 舒兰市| 永康市| 清丰县| 依安县| 西乌珠穆沁旗| 霍林郭勒市| 东乌珠穆沁旗| 乐平市| 龙岩市| 松溪县| 旬阳县|