binrw
binrw copied to clipboard
Add a `multi` helper for reading a slice of args
This works similarly to count
, but takes &[Args]
instead of using a length + cloning the same args.
Name might not be the best -- I avoided using the more obvious map
as unlike count
this is not analogous to the map
attribute.
How does compose
(as in object composition) sound? (it may or may not make sense in this context, I'm not sure, but it's what came to mind haha)
what about for_each?
It looks like I accidentally superseded this PR by not paying attention 😵💫 and writing and committing a similar helper function. The differences between the two appear to be:
- This implementation includes a Vec
optimisation, but I don’t think it is needed since Vec takes no arguments anyway so wouldn’t be using this helper; - The committed implementation accepts anything that is
IntoIterator<Item = Arg>
, so it works with slices but also any other thing that is convertible to an iterator; - The committed implementation takes the arguments as a parameter into the helper function, rather than indirectly via
args
, which is hopefully a little less ‘weird’ than needing to pass a slice in withargs_raw
.
As such, I am going to close this PR for now. Please feel free to reopen if I have made some mistake. Thanks!