我不喜欢的 Rust 特性 (之一) eager drop
2024-08-30 23:52:54
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!
最新文章
- jdbc的实例应用:增删查改实现
- 【GoLang】GoLang struct 使用
- 配置DNS服务器
- phpstormn 中 xdebug 的详细配置2
- Windows 8.1 开发过程中遇到的小问题
- Calendar的问题
- C#线程
- matlab 小波变换
- Team Foundation Server 2013 with Update 3 Install LOG
- chrome调试工具常用功能整理(转)
- windows socket函数详解
- Nginx负载均衡策略
- [图解Java]Condition
- servlet实现mysql数据库分页
- Codeforces Round #553 (Div. 2) D题
- ruby-super用法
- [Vuex] Create a Vuex Store using TypeScript
- java控制流
- mysql 字符串数值计算 精度丢失
- Ubuntu学习总结-01 安装Ubuntu
热门文章
- 洛谷 P1414 又是毕业季II(未完成)
- tablespace monitor shell for windows
- Windows 7上安装Microsoft Loopback Adapter(微软环回网卡)
- Git命令add和commit的区别
- 树莓派zero_w设置中文(已成功)
- 微信小程序打卡第五天
- springboot项目中,@transactional 无效
- shim和polyfill有什么区别
- windows多线程应用编程注意事项
- Slow HTTP Denial of Service Attack 漏洞解决办法