似乎您不能.如果没有,是否有计划添加它或运行时类型信息(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 => {
// ...
}
}
}
这个例子微不足道.如果它在现实生活中有多种用途的话.e、 g.let x = function_with_multiple_return_types();
.