georust / transitfeed

Public transit serializer/deserializer and manipulation library for Rust
Apache License 2.0
16 stars 4 forks source link

Improve ergonomics of adding new iterators #2

Closed medwards closed 7 years ago

medwards commented 7 years ago

Adding the new iterators was kind of a drag, in particular there is a lot of generic boiler plate stuff.

I've made a prototype of what this might look like in https://github.com/medwards/transitfeed/blob/dff5d12de20c1d4f016ea0cb55ab0b15a9c756f2/src/gtfs/stop_times.rs and would like your feedback.

Basically GTFSIterator accepts a Csv like it does now but also a parsing function that it applies during the iteration.

GTFSIterator would end up in gtfs/gtfs.rs or gtfs/mod.rs and I'm thinking of adding a function that does the composition for you if you pass the filepath. I also want to move error capturing/transformation up to GTFSIterator.next instead of it happening in various places (value parsing functions, etc.)

Let me know what you think!

medwards commented 7 years ago

I'm impatient so I just went ahead and did it XD medwards/transitfeed@e99e68a9a29636b70266be1516725e09f112862a

teburd commented 7 years ago

This is a nice set of changes and definitely DRY's some stuff up.

I've been debating on moving things to the csv crate in the future once 1.0 is out, this seems like it would atleast begin helping reduce the amount of changes needed for that as well.

Great stuff! Send a PR when its ready and I'll review.