I'm trying to make a compiler in Rust, but I'm having problems understanding how to define a type hierarchy using enumerations. We have for example:
enum Thing {
Animal,
Plant,
}
struct Plant {
color: String,
}
enum Animal {
Dog,
Cat,
}
struct Cat {
name: String,
}
struct Dog {
name: String,
}
let x = Dog { name: john };
If I do pattern matching, will Dog be considered of Animal type (or Thing type)? How do I create this type hierarchy using enums and structs? My type hierarchy has many levels of depth.