blyxxyz / lexopt

Minimalist pedantic command line parser
MIT License
294 stars 9 forks source link

Use std::vec::IntoIter as Parser's backing iterator #16

Closed blyxxyz closed 1 year ago

blyxxyz commented 1 year ago

lexopt currently uses Box<dyn Iterator> but this is very restrictive. By switching to a vector's iterator we can derive common traits like Clone and get unlimited look-ahead.

This isn't strictly backward-compatible. The iterator is now exhausted when you create the parser, not during parsing. Sufficiently perverse code like this can observe it, and it might be out in the wild, so I'm bumping the version to 0.3.0. Such code can hopefully use RawArgs::as_slice() instead, especially when #15 is implemented.

Parser could implement FromIterator now, and RawArgs could provide mutable access, but I'm not sure those are useful so I left them out.

Both this change and the version bump seem like the right thing to do, but comments welcome.

cc @nordzilla @tertsdiepraam