好像你不能.如果没有,是否有计划支持添加它或运行时类型信息(RTTI)?
struct Bus;
struct Car;
struct Person;
fn main() {
let x = Bus;
//or more realistically, let x = function_with_multiple_return_types();
match x {
Car => {
// ...
}
Bus => {
// this gets executed
}
Person => {
// ...
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个例子很简单.在现实生活中,只有x多种类型才有用.例如let x = function_with_multiple_return_types();.