Skip to content

Commit

Permalink
Return opaque iterator for nearest neighbor searches
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Jan 6, 2025
1 parent 327c549 commit 2a1ccd5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rtree/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub trait RTreeIndex<N: IndexableNum>: Sized {
y: N,
max_results: Option<usize>,
max_distance: Option<N>,
) -> Vec<u32> {
) -> impl Iterator<Item = u32> {
let boxes = self.boxes();
let indices = self.indices();
let max_distance = max_distance.unwrap_or(N::max_value());
Expand Down Expand Up @@ -212,7 +212,7 @@ pub trait RTreeIndex<N: IndexableNum>: Sized {
}
}

results
results.into_iter()
}

/// Search items in order of distance from the given coordinate.
Expand All @@ -221,7 +221,7 @@ pub trait RTreeIndex<N: IndexableNum>: Sized {
coord: &impl CoordTrait<T = N>,
max_results: Option<usize>,
max_distance: Option<N>,
) -> Vec<u32> {
) -> impl Iterator<Item = u32> {
self.neighbors(coord.x(), coord.y(), max_results, max_distance)
}

Expand Down

0 comments on commit 2a1ccd5

Please sign in to comment.