From 2a1ccd5e3c66b01084db4612ea5f43b737e64e6d Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 6 Jan 2025 11:28:55 -0500 Subject: [PATCH] Return opaque iterator for nearest neighbor searches --- src/rtree/trait.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rtree/trait.rs b/src/rtree/trait.rs index d621c69..aeaa3d2 100644 --- a/src/rtree/trait.rs +++ b/src/rtree/trait.rs @@ -151,7 +151,7 @@ pub trait RTreeIndex: Sized { y: N, max_results: Option, max_distance: Option, - ) -> Vec { + ) -> impl Iterator { let boxes = self.boxes(); let indices = self.indices(); let max_distance = max_distance.unwrap_or(N::max_value()); @@ -212,7 +212,7 @@ pub trait RTreeIndex: Sized { } } - results + results.into_iter() } /// Search items in order of distance from the given coordinate. @@ -221,7 +221,7 @@ pub trait RTreeIndex: Sized { coord: &impl CoordTrait, max_results: Option, max_distance: Option, - ) -> Vec { + ) -> impl Iterator { self.neighbors(coord.x(), coord.y(), max_results, max_distance) }