News for hackers. Stuff that matters.
Re:Irregular Expressions by umanwizard on Sunday April 09, 2023 @04:15PM (#35506056)
It's currently not possible to write a Rust function that's generic over a tuple with arbitrarily many entries, so they had to implement a trait by hand for tuple sizes up to 21 (presumably that limit was chosen arbitrarily).
Re:Irregular Expressions by metadat on Sunday April 09, 2023 @06:51PM (#35507265)
Does Rust have a template or macro system that would facilitate generating up to e.g. 221 instead?

If I'm understanding correctly, some Regex features may require implementing more than 21 rules for a thorough and complete implementation.

Re:Irregular Expressions by iudqnolq on Sunday April 09, 2023 @07:23PM (#35507448)
Yes, rust declarative macros shine at exactly this kind of problem. And nom does use this to generate the implementation.

But for some reason it's customary in rust to stick to a lower number of autogenerated implementations. My first guess would be it might be a compile time issue?

https://docs.rs/nom/latest/src/nom/branch/mod.rs.html#245

Re:Irregular Expressions by jcparkyn on Sunday April 09, 2023 @07:14PM (#35507397)
The workaround is just to nest multiple `alt`s inside each other.