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

Views :
Update time : 2025-06-23 07:30:10

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 Golang 中为什么没有注解?
2025-06-23 01:50:10
Golang 中为什么没有注解?...
Blog Post With Youtube Video 为什么苹果公司无法制造出性价比高的 Mac 电脑?
2025-06-23 02:55:09
为什么苹果公司无法制造出性价比高的 Mac 电脑?...
Blog Post With Youtube Video postgresql也很强大,为何在中国大陆,mysql成为主流,postgresql屈居二线呢?
2025-06-23 02:25:10
postgresql也很强大,为何在中国大陆,mysql成为主流,postgresql屈居二线呢?...
Blog Post With Youtube Video Rust 的设计缺陷是什么?
2025-06-23 02:05:10
Rust 的设计缺陷是什么?...

Leave Your Message