It seems as though you can't. If not, is there any planned support to add it or run-time type information (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 => {
// ...
}
}
}
This example is trivial. In real life, it would only be useful if x
could be multiple types. e.g. let x = function_with_multiple_return_types();
.