Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重写所有权大节:采用通俗易懂,循序渐进逐步深入的表达方式 #95

Merged
merged 3 commits into from
Mar 28, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
重写所有权大节:采用通俗易懂,循序渐进逐步深入的表达方式
  • Loading branch information
gaobushuang committed Mar 28, 2016
commit 69af41dd1d71eb30a29f1b0407002b4721448055
3 changes: 2 additions & 1 deletion 13-ownership-system/13-01-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ fn main() {
```
> **报错:**
error: use of moved value: `x` [E0382]
<anon>:5 println!("x={:?}", x);
<anon>:5 println!("x={:?}", x);

这是因为move关键字,会把闭包中的外部变量的所有权move到包体内,发生了所有权转移的问题,所以println访问x会如上错误。如果我们去掉println就可以编译通过。

那么,如果我们想在包体外依然访问x,即x不失去所有权,怎么办?
Expand Down