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

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.

主站蜘蛛池模板: 琼中| 海兴县| 宁夏| 电白县| 乌鲁木齐市| 仙桃市| 松阳县| 乳源| 大渡口区| 揭东县| 慈溪市| 双鸭山市| 逊克县| 磴口县| 保亭| 土默特左旗| 黑水县| 山东| 瑞安市| 佳木斯市| 双牌县| 会昌县| 沂南县| 河池市| 嘉峪关市| 翼城县| 东兰县| 固镇县| 中宁县| 兴城市| 青神县| 剑阁县| 岢岚县| 陇西县| 永顺县| 布尔津县| 寿光市| 邵阳市| 山丹县| 新乡县| 赣榆县|