Open Miro-Andrin opened 4 years ago
I think we should leave this until const generics are stabilized, we can then do parser::<Range<i32, 0, 100>>()
. Right now we can do this, however, it requires a custom type for all ranges.
There's also the option
fn range<T, P<T>>(parser: P, min: T, max: T) -> impl Parser where
T: std::cmp::Ord,
P: Parser<T>;
range(parser::<i32>(), 0, 100)
The commands.json file describes parsers as a combination of a base parsers plus a modifier. Some examples:
When i am trying to generate rust/lieutenant code i need to work around this, because lieutenant does not sport properties/modifiers. As a hacky solution i treat every combination of "parser" + "properties" as a unique parser. This works but is not elegant.
A list of every parser referenced in commands.json, as of Minecraft 1.16:
As you can see most of the parsers that have a modifier are actually the numeric types, so if a generic solution is not wanted, or is to much of a hassle, then at least consider adding it for the numeric types. However the generic solution would be appreciated.