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

  • Learning Rust
  • Paul Johnson Vesa Kaihlavirta
  • 104字
  • 2021-07-02 23:07:19

Passing values around

Up to this point, we have kept everything within a single method. For small demonstrations (or for method testing), this is fine. However, for larger applications, passing values between methods is essential.

Rust has two main ways to pass information to other methods: by reference or by value. Passing by reference usually implies borrowing, which means that ownership is only temporarily given and can be used again after the function call. Passing by value implies either a permanent ownership change, which means that the caller of a function can no longer access the value, or it might imply copying the data.

主站蜘蛛池模板: 汉沽区| 连平县| 罗山县| 宣城市| 定日县| 泰顺县| 建瓯市| 连城县| 岑溪市| 孟连| 三门峡市| 金平| 屯留县| 双桥区| 屏山县| 泾源县| 遵化市| 玉环县| 浮梁县| 商河县| 攀枝花市| 镇康县| 南陵县| 嵊泗县| 虎林市| 丰县| 文登市| 安图县| 南汇区| 射阳县| 岚皋县| 蓝山县| 乳山市| 陵水| 青河县| 灵山县| 河西区| 定州市| 南澳县| 交口县| 遂宁市|