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 为什么不用rust重写Nginx?
2025-06-20 09:25:18
为什么不用rust重写Nginx?...
Blog Post With Youtube Video 长期使用的大佬来说说,MacOS 真的比 Windows 稳定吗?
2025-06-20 09:30:18
长期使用的大佬来说说,MacOS 真的比 Windows 稳定吗?...
Blog Post With Youtube Video 有人 espresso 直接喝吗,为什么?
2025-06-20 08:35:17
有人 espresso 直接喝吗,为什么?...
Blog Post With Youtube Video 有没有人***正好撞到你擅长的领域上的?
2025-06-20 08:20:17
有没有人***正好撞到你擅长的领域上的?...

Leave Your Message