提交 d4d21b42 编写于 作者: P Patrick Walton

tutorial: Mention how the destructor works in the section on resources. Closes #1615.

上级 857ad58d
......@@ -1329,10 +1329,11 @@ resource file_desc(fd: int) {
~~~~
This defines a type `file_desc` and a constructor of the same name,
which takes an integer. Values of such a type can not be copied, and
when they are destroyed (by going out of scope, or, when boxed, when
their box is cleaned up), their body runs. In the example above, this
would cause the given file descriptor to be closed.
which takes an integer. The type has an associated destructor procedure,
whose contents are specified by the block. Values of such a type can not
be copied, and when they are destroyed (by going out of scope, or, when
boxed, when their box is cleaned up), their body runs. In the example
above, this would cause the given file descriptor to be closed.
NOTE: We're considering alternative approaches for data types with
destructors. Resources might go away in the future.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册