struct Foo;

impl Drop for Foo {
fn drop(&mut self) {
println!("drop");
}
} fn main() {
let _ = Foo;
println!("After");
}

http://is.gd/SQ6vcn

输出是

drop
After

而如果我们换成:

struct Foo;

impl Drop for Foo {
fn drop(&mut self) {
println!("drop");
}
} fn main() {
let x = Foo;
let _ = x;
println!("After");
}

http://is.gd/uvJMO0

After
drop

虽然 eager drop 是很好的东西,但是,我们其实不需要啊!

我们明明可以显式地给返回值调用一个 drop!

最新文章

  1. jdbc的实例应用:增删查改实现
  2. 【GoLang】GoLang struct 使用
  3. 配置DNS服务器
  4. phpstormn 中 xdebug 的详细配置2
  5. Windows 8.1 开发过程中遇到的小问题
  6. Calendar的问题
  7. C#线程
  8. matlab 小波变换
  9. Team Foundation Server 2013 with Update 3 Install LOG
  10. chrome调试工具常用功能整理(转)
  11. windows socket函数详解
  12. Nginx负载均衡策略
  13. [图解Java]Condition
  14. servlet实现mysql数据库分页
  15. Codeforces Round #553 (Div. 2) D题
  16. ruby-super用法
  17. [Vuex] Create a Vuex Store using TypeScript
  18. java控制流
  19. mysql 字符串数值计算 精度丢失
  20. Ubuntu学习总结-01 安装Ubuntu

热门文章

  1. 洛谷 P1414 又是毕业季II(未完成)
  2. tablespace monitor shell for windows
  3. Windows 7上安装Microsoft Loopback Adapter(微软环回网卡)
  4. Git命令add和commit的区别
  5. 树莓派zero_w设置中文(已成功)
  6. 微信小程序打卡第五天
  7. springboot项目中,@transactional 无效
  8. shim和polyfill有什么区别
  9. windows多线程应用编程注意事项
  10. Slow HTTP Denial of Service Attack 漏洞解决办法