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

  • 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.

主站蜘蛛池模板: 开江县| 天等县| 林州市| 宁陵县| 潮州市| 东乡| 松江区| 遂川县| 溧水县| 赤水市| 安泽县| 沧州市| 南城县| 和田市| 缙云县| 新安县| 盐亭县| 台中县| 镇原县| 高青县| 永平县| 闵行区| 金乡县| 龙胜| 洛阳市| 云安县| 申扎县| 商南县| 泗洪县| 宁武县| 白玉县| 苏尼特左旗| 邵东县| 塘沽区| 连云港市| 镇原县| 张家川| 当阳市| 疏附县| 靖江市| 十堰市|