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

Views :
Update time : 2025-06-20 18:05:16

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 为什么有人爱 Firefox 胜过 Chrome 呢?
2025-06-20 22:35:16
为什么有人爱 Firefox 胜过 Chrome 呢?...
Blog Post With Youtube Video antv x6 node 点击***不触发怎么办?
2025-06-20 22:30:16
antv x6 node 点击***不触发怎么办?...
Blog Post With Youtube Video golang 与rust 在服务器程序领域相比较,各有什么优劣势?
2025-06-20 22:00:15
golang 与rust 在服务器程序领域相比较,各有什么优劣势?...
Blog Post With Youtube Video 中国有能打到美国本土的导弹吗……有的话最远能打到哪里呢?
2025-06-20 22:35:16
中国有能打到美国本土的导弹吗……有的话最远能打到哪里呢?...

Leave Your Message