Rust 中的 Some 和 Option 有什么区别? [英] What is the difference between Some and Option in Rust?
本文介绍了Rust 中的 Some 和 Option 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它们是一样的吗?我有时可以看到文档使用它们,就好像它们是平等的一样.
Are they the same? I can sometimes see the documentation use them as if they were equal.
推荐答案
Option
类型定义为:
enum Option<T> {
None,
Some(T),
}
这意味着 Option
类型可以具有 None
或 Some
值.
Which means that the Option
type can have either a None
or a Some
value.
另见:
这篇关于Rust 中的 Some 和 Option 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文