- 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.
推薦閱讀
- Learning Single:page Web Application Development
- The Modern C++ Challenge
- TensorFlow Lite移動端深度學習
- Ceph Cookbook
- Hands-On Image Processing with Python
- 技術領導力:程序員如何才能帶團隊
- Julia機器學習核心編程:人人可用的高性能科學計算
- R大數據分析實用指南
- Unity 2D Game Development Cookbook
- C#程序設計(項目教學版)
- Python從入門到精通(第3版)
- Instant Zurb Foundation 4
- WordPress Search Engine Optimization(Second Edition)
- HTML5與CSS3權威指南
- H5匠人手冊:霸屏H5實戰解密