- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 129字
- 2021-07-02 23:07:26
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.
推薦閱讀
- FuelPHP Application Development Blueprints
- Java程序設計實戰教程
- Visual Basic 6.0程序設計計算機組裝與維修
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- PHP 從入門到項目實踐(超值版)
- C語言程序設計案例式教程
- C語言實驗指導及習題解析
- Web程序設計(第二版)
- Mastering Data Mining with Python:Find patterns hidden in your data
- Quantum Computing and Blockchain in Business
- Spring Boot+MVC實戰指南
- R數據科學實戰:工具詳解與案例分析
- 算法圖解
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- 零基礎學編程系列(全5冊)