Rust 使用 Result 的错误处理方式与 Golang 使用 error 的方式有什么本质区别?

Views :
Update time : 2025-06-20 02:55:15

rust 的 result 是枚举,只有2个答案,要么ok要么不ok,不ok的时候,err带错误信息。

golang 的 error ,只是多返回值,***设有2个返回值,其实一个给了error,那么用户可以造4个组合的返回: 1,有返回值,有error 2,有返回值,无error 3,无返回值,无error 4,无返回值,有error 理论上,google 希望的是2和4。

虽然现实多数也是这么用的,但是我真碰到过1和3的。

这时候,就很惆怅 ‍ ‍ ‍ 。

只要碰到过一次,你就蛋疼了。

因…。

Rust 使用 Result 的错误处理方式与 Golang 使用 error 的方式有什么本质区别?
Related News
Read More >>
Blog Post With Youtube Video 如果全球都停止出口粮食,中国能否自给自足?
2025-06-20 20:20:16
如果全球都停止出口粮食,中国能否自给自足?...
Blog Post With Youtube Video ant-design-vue 社区为什么不维护了?
2025-06-20 20:55:15
ant-design-vue 社区为什么不维护了?...
Blog Post With Youtube Video Golang web项目求推荐?
2025-06-20 19:10:16
Golang web项目求推荐?...
Blog Post With Youtube Video 如何看待青鸾峰上连续几本***霸占纵横榜首?
2025-06-20 19:30:16
如何看待青鸾峰上连续几本***霸占纵横榜首?...

Leave Your Message