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

Views :
Update time : 2025-06-24 20:10:15

Go 即不要求 err 为 nil 时,result 是非 nil。

也不要求 result 为 非 nil 时,err 为 nil。

所以理论上,Go 存在 如下四种情况 值, nilnil, errnil, nil值, err而 Rust 的 Resut 只存在两种情况。

ok 或 err 有人可能会说,只要做好规定,让开发者不这么写就可以了。

你说的对,但,能从语言层面确定的,为什么要靠人来限制。

你能保证你永远不犯错吗? 你连团队里面是不是有人给 err _ 了都保证不了。

人,才是最难保证的一环…。

Rust 使用 Result 的错误处理方式与 Golang 使用 error 的方式有什么本质区别?
Related News
Read More >>
Blog Post With Youtube Video 工业克苏鲁什么意思?
2025-06-24 18:50:16
工业克苏鲁什么意思?...
Blog Post With Youtube Video 刘强东看到了什么,才去搞外卖?
2025-06-24 18:40:16
刘强东看到了什么,才去搞外卖?...
Blog Post With Youtube Video 你做过最抽象的事情是什么?
2025-06-24 18:15:16
你做过最抽象的事情是什么?...
Blog Post With Youtube Video OpenWrt 能做哪些有趣的事?
2025-06-24 18:05:16
OpenWrt 能做哪些有趣的事?...

Leave Your Message