File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ Rust **确实**包含了打印出调试信息的功能,不过我们必须为
140140{{#include ../listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt}}
141141```
142142
143- 我们可以看到第一点输出来自 * src/main.rs* 第 10 行,我们正在调试表达式 ` 30 * scale ` ,其结果值是60(为整数实现的 ` Debug ` 格式化是只打印它们的值)。在 * src/main.rs* 第 14 行的 ` dbg! ` 调用输出 ` &rect1 ` 的值,, 即 ` Rectangle ` 结构。这个输出使用了更为易读的 ` Debug ` 格式。当你试图弄清楚你的代码在做什么时,` dbg! ` 宏可能真的很有帮助!
143+ 我们可以看到第一点输出来自 * src/main.rs* 第 10 行,我们正在调试表达式 ` 30 * scale ` ,其结果值是60(为整数实现的 ` Debug ` 格式化是只打印它们的值)。在 * src/main.rs* 第 14 行的 ` dbg! ` 调用输出 ` &rect1 ` 的值,即 ` Rectangle ` 结构。这个输出使用了更为易读的 ` Debug ` 格式。当你试图弄清楚你的代码在做什么时,` dbg! ` 宏可能真的很有帮助!
144144
145145除了 ` Debug ` trait,Rust 还为我们提供了很多可以通过 ` derive ` 属性来使用的 trait,他们可以为我们的自定义类型增加实用的行为。[ 附录 C] [ app-c ] <!-- ignore --> 中列出了这些 trait 和行为。第十章会介绍如何通过自定义行为来实现这些 trait,同时还有如何创建你自己的 trait。除了 ` derive ` 之外,还有很多属性;更多信息请参见 [ 《Rust 参考手册》] [ attributes ] 的 Attributes 部分。
146146
You can’t perform that action at this time.
0 commit comments