- 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.
推薦閱讀
- Java Web基礎與實例教程(第2版·微課版)
- Git高手之路
- 假如C語言是我發明的:講給孩子聽的大師編程課
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Visual Basic程序設計與應用實踐教程
- PySide GUI Application Development(Second Edition)
- MATLAB for Machine Learning
- Teaching with Google Classroom
- Python數據結構與算法(視頻教學版)
- Python Data Structures and Algorithms
- NetBeans IDE 8 Cookbook
- Visual Studio 2015高級編程(第6版)
- 大話Java:程序設計從入門到精通
- QGIS 2 Cookbook
- Backbone.js Testing