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

Views :
Update time : 2025-06-21 12:55:18

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-21 01:10:18
阿里网盘为什么没有动静了?...
Blog Post With Youtube Video 为何雷军天天健身,却无健身痕迹?
2025-06-21 02:15:16
为何雷军天天健身,却无健身痕迹?...
Blog Post With Youtube Video 如何评价***伊内斯·特洛奇亚的身材?
2025-06-21 02:20:16
如何评价***伊内斯·特洛奇亚的身材?...
Blog Post With Youtube Video 中国军队有多强,在世界能排第几?
2025-06-21 02:25:17
中国军队有多强,在世界能排第几?...

Leave Your Message