I'm not much into Rust and I look into it when I need to check whether it's possible to do some interesting things using its type system. And I've come up with a question if it's possible to convert the following type definitions written in TS to Rust.
type Data = {
path: String
name: String
}
enum Type {
CSV,
JPG,
PNG
}
type CSV = Data & {
type: Type.CSV
}
type JPG = Data & {
type: Type.PNG
}
type PNG = Data & {
type: Type.PNG
}
// To avoid conflicts with the already reserved type File
type MyFile = CSV | PNG | JPG
I've been trying to google something like if it's possible to extend structs in Rust and unfortunately didn't find anything answering my curiosity.