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

  • Learning Rust
  • Paul Johnson Vesa Kaihlavirta
  • 89字
  • 2021-07-02 23:07:25

Let's start at the beginning

In Chapter 2, Variables, I briefly mentioned how data is stored within memory, and I said that non-compound types, such as i32, are stored on the stack, whereas, the likes of String, Vector<T>, types, and such are stored on the heap.

By default, Rust stores data on the stack, as it's incredibly fast. There are drawbacks though. The stack is limited in size and the allocation only lasts for the lifetime of the function.

The question is, how much memory does a function take?

主站蜘蛛池模板: 五原县| 石柱| 丁青县| 淮北市| 于都县| 桂东县| 枝江市| 大英县| 赫章县| 冕宁县| 都昌县| 富阳市| 洞头县| 尚义县| 晴隆县| 中宁县| 鹿邑县| 军事| 班戈县| 湖南省| 榆树市| 蒙山县| 图们市| 阜康市| 陆河县| 汤原县| 渭源县| 漳州市| 聂荣县| 霍城县| 南郑县| 黑河市| 竹山县| 台东县| 长乐市| 且末县| 新和县| 图木舒克市| 阳信县| 万盛区| 晴隆县|