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

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.

主站蜘蛛池模板: 浏阳市| 盘锦市| 靖远县| 安义县| 垦利县| 蚌埠市| 哈巴河县| 海门市| 巴马| 耒阳市| 大安市| 阳东县| 大安市| 江永县| 巫山县| 阳朔县| 长阳| 岳普湖县| 杭州市| 韶关市| 佛冈县| 溧水县| 许昌市| 增城市| 双鸭山市| 平顺县| 保靖县| 温泉县| 邵阳县| 二手房| 千阳县| 崇阳县| 邵阳县| 长寿区| 娄烦县| 灵丘县| 岳普湖县| 岢岚县| 健康| 报价| 呼图壁县|