In HTTP headers, in Language Tags and in many other places you give a value or allow all values with a *
.
Like the MIME-Type application/*
will match both application/json
and application/xml
, because of the wildcard star used.
So what is the preferred way to express such values?
The two common ways I have seen are the following:
Either add a wildcard variant to the enum
enum Mimetype {
Star,
ApplicationJson,
ApplicationXml,
...
}
Or use an Option
enum Mimetype {
ApplicationJson,
ApplicationXml,
...
}
and than use it as Option<Mimetype>
in other structs. This consumes one extra byte for the option, but this could probably be optimised by compiler magic.
Which option fits better into Rust, and is therefore preferred, or can these types get expressed in even more ways?