全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Move?

又称: move (Rust)

Definition 6.3 University Computer Science — Year 2 · 第 6 章 — Rust: Ownership and Borrowing

A move transfers ownership of a value: an assignment let b = a;, the passing of a as an argument by value, or its return from a function copies the bytes of a’s stack part to the destination, which becomes the owner. The source is then moved from: the compiler refuses any later use of it, and does not drop it.

A move of a String. The three words of a are copied into b; the buffer stays where it is, with one owner, b. The compiler forbids any use of a afterwards and drops only b, so the buffer is freed exactly once. In C++, a move would also have emptied a, and run its destructor later; in Rust nothing runs on a at all.
A move of a String. The three words of a are copied into b; the buffer stays where it is, with one owner, b. The compiler forbids any use of a afterwards and drops only b, so the buffer is freed exactly once. In C++, a move would also have emptied a, and run its destructor later; in Rust nothing runs on a at all.
在原文中阅读 →