georust / rstar

R*-tree spatial index for the Rust ecosystem
https://docs.rs/rstar
Apache License 2.0
414 stars 68 forks source link

rtree.nearest_neighbor_iter_with_distance_2 family returns private iterator types #185

Closed blaa closed 2 weeks ago

blaa commented 2 weeks ago

Maybe this problem is a PEBKAC, but maybe things could be simpler.

rstar has iterators.rs module that's publicly reexported in lib.rs. But Nearest Neighbors iterators are defined in private mod algorithm::nearest_neighbors and can't be reached.

I want to create an iterator that consumes iterator that is returned by rtree, do something with the data and in general create abstraction that hides rtree as implementation detail. Currently I'm trying (unsuccessfully so far) to do a iterator that's generic over anything implementing Iterator trait that has specific Item. But is that required? (is that even possible?)

Are those iterators hidden for purpose, or just forgotten?

edit: Being generic over Iterator works, just feels too complicated for what I need. ;)

adamreichold commented 2 weeks ago

I think not re-exporting those is a bug.

blaa commented 2 weeks ago

My generic over Iterator struct also fails later; It compiles as long as I don't return it further. I probably must Box it and use dyn. Still feels rather complicated.