ZhangHanDong / tao-of-rust-codes

《Rust编程之道》随书源码
https://ruststudy.github.io/tao_of_rust_docs/tao_of_rust/
MIT License
1.19k stars 172 forks source link

[第四章] 代码清单4-3 代码返回结果和后面的描述有误 #273

Closed xiaods closed 4 years ago

xiaods commented 4 years ago

103页,代码清单4-3 代码返回结果和后面的描述有误

play运行链接

书中说8,实际返回为16。后面描述中说以联合体最大字长变量f3为返回值。实际为3个变量字长之和返回。

ZhangHanDong commented 4 years ago

@xiaods 感谢反馈

zydxhs commented 4 years ago

@xiaods @ZhangHanDong 代码清单中写的是 union ,不是 struct,因此 union 的大小是 8 字节。

xiaods commented 4 years ago

@zydxhs my bad. close it.