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

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.

主站蜘蛛池模板: 玉门市| 泾川县| 苍溪县| 前郭尔| 奈曼旗| 桑植县| 宜良县| 正定县| 宣武区| 安新县| 大悟县| 凤山县| 香河县| 平遥县| 上虞市| 古丈县| 塔河县| 商都县| 景宁| 望谟县| 昌乐县| 吉安市| 左贡县| 个旧市| 长宁县| 伊宁市| 康定县| 开封县| 富民县| 湛江市| 新沂市| 蓬安县| 柳河县| 衡阳市| 且末县| 浮梁县| 米泉市| 东丰县| 桃源县| 海丰县| 资阳市|